Automated Action ba478ce2d3 Implement Task Manager API with FastAPI and SQLite
Create a full-featured task management API with the following components:
- RESTful CRUD operations for tasks
- Task status and priority management
- SQLite database with SQLAlchemy ORM
- Alembic migrations
- Health check endpoint
- Comprehensive API documentation
2025-05-30 22:50:55 +00:00

29 lines
605 B
Python

"""
Database session configuration.
"""
from pathlib import Path
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
DB_DIR = Path("/app") / "storage" / "db"
DB_DIR.mkdir(parents=True, exist_ok=True)
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"
engine = create_engine(
SQLALCHEMY_DATABASE_URL,
connect_args={"check_same_thread": False}
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
def get_db():
"""
Get a database session.
"""
db = SessionLocal()
try:
yield db
finally:
db.close()