Automated Action c1765ee96b Implement Task Manager API
- Set up project structure with FastAPI
- Configure SQLite database with SQLAlchemy
- Create Task model with Alembic migrations
- Implement CRUD API endpoints for tasks
- Add health check and CORS configuration
- Update documentation
2025-06-04 08:04:34 +00:00

27 lines
709 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
# Ensure the DB directory exists
settings.DB_DIR.mkdir(parents=True, exist_ok=True)
# Create SQLAlchemy engine
engine = create_engine(
settings.SQLALCHEMY_DATABASE_URL,
connect_args={"check_same_thread": False} # Only needed for SQLite
)
# Create SessionLocal class
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
# Create Base class for models
Base = declarative_base()
# Dependency to get DB session
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()