Automated Action af0f9e1638 Build barebones task manager API with FastAPI and SQLite
- Create FastAPI application with CORS support
- Implement Task model with SQLAlchemy
- Set up database session and migrations with Alembic
- Add CRUD endpoints for task management
- Include health check and API documentation endpoints
- Configure Ruff for code formatting and linting
2025-06-18 00:22:56 +00:00

23 lines
518 B
Python

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