Automated Action f24dc4e301 Create simple inventory application with FastAPI and SQLite
- Set up FastAPI project structure
- Configure SQLite database with SQLAlchemy
- Create Item model and schemas
- Implement CRUD endpoints for inventory items
- Set up Alembic for database migrations
- Add comprehensive documentation
2025-06-17 01:50:57 +00:00

18 lines
470 B
Python

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from app.core.config import settings
engine = create_engine(
settings.SQLALCHEMY_DATABASE_URL,
connect_args={"check_same_thread": False} # Required for SQLite
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
# Dependency for endpoints to get the DB session
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()