Automated Action 29d75cdf08 Implement Task Management API with FastAPI and SQLite
- Set up project structure and dependencies
- Create database models and schemas for tasks
- Implement CRUD operations for tasks
- Add API endpoints for task management
- Create Alembic migrations for the database
- Add health check endpoint
- Implement error handling
- Add documentation in README.md
2025-05-17 11:20:00 +00:00

26 lines
586 B
Python

from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from app.core.config import settings
SQLALCHEMY_DATABASE_URL = f"sqlite:///{settings.DB_DIR}/db.sqlite"
engine = create_engine(
SQLALCHEMY_DATABASE_URL,
connect_args={"check_same_thread": False}
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
def get_db():
"""Get SQLAlchemy database session."""
db = SessionLocal()
try:
yield db
finally:
db.close()