Automated Action 7658939790 Create Task Manager API with FastAPI and SQLite
- Set up project structure and dependencies
- Create task model and schema
- Implement Alembic migrations
- Add CRUD API endpoints for task management
- Add health endpoint with database connectivity check
- Add comprehensive error handling
- Add tests for API endpoints
- Update README with API documentation
2025-06-04 22:52:31 +00:00

28 lines
708 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
# SQLite database URL
SQLALCHEMY_DATABASE_URL = f"sqlite:///{settings.DB_DIR}/db.sqlite"
# Create SQLAlchemy engine
engine = create_engine(
SQLALCHEMY_DATABASE_URL,
connect_args={"check_same_thread": False} # Only needed for SQLite
)
# Create session factory
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
# Create base class for models
Base = declarative_base()
# Dependency for getting DB session
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()