
- 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
13 lines
236 B
Python
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() |