Automated Action 168878cd6f Create Simple Todo Application with FastAPI and SQLite
- Set up project structure and dependencies
- Implement Todo model with SQLAlchemy
- Configure SQLite database connection
- Create Alembic migration scripts
- Implement RESTful API endpoints for CRUD operations
- Add health check endpoint
- Update README with documentation

generated with BackendIM... (backend.im)
2025-05-13 02:14:09 +00:00

18 lines
432 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} # Needed for SQLite
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
# Dependency
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()