Automated Action cb4f834fc3 Implement complete Task Manager API with FastAPI
- Set up FastAPI application with CORS support
- Created SQLAlchemy models for task management
- Implemented CRUD operations for tasks
- Added database migrations with Alembic
- Created REST API endpoints for task operations
- Added health check endpoint
- Updated README with comprehensive documentation
- Applied code formatting with Ruff
2025-06-19 21:12:16 +00:00

23 lines
521 B
Python

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from pathlib import Path
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()