todoapp-hsg61m/app/db/session.py
Automated Action 5dca451d03 Add SQLAlchemy database setup with Todo model
- Add app/db/base.py with SQLAlchemy Base class
- Add app/db/session.py with SQLite database connection using absolute path
- Add app/models/todo.py with Todo model including all required fields
- Add empty __init__.py files for proper package structure
2025-06-19 17:46:14 +00:00

13 lines
236 B
Python

from sqlalchemy.orm import Session
from app.db.base import SessionLocal
def get_db() -> Session:
"""
Dependency to get database session.
"""
db = SessionLocal()
try:
yield db
finally:
db.close()