Automated Action 206bdd171b Implement Task Management API with FastAPI
- Create complete task management system with CRUD operations
- Add Task model with status, priority, timestamps
- Set up SQLite database with SQLAlchemy and Alembic migrations
- Implement RESTful API endpoints for task operations
- Configure CORS middleware and API documentation
- Add health check endpoint and root information response
- Include proper project structure and comprehensive README
2025-07-01 23:01:59 +00:00

28 lines
615 B
Python

from pathlib import Path
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from app.db.base import Base
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():
db = SessionLocal()
try:
yield db
finally:
db.close()
def create_tables():
Base.metadata.create_all(bind=engine)