Automated Action 3625685e4f Add complete Task Manager API with FastAPI and SQLite
- Created FastAPI application with CRUD operations for tasks
- Implemented SQLAlchemy models with Task entity
- Added Pydantic schemas for request/response validation
- Set up Alembic for database migrations
- Configured SQLite database with proper file structure
- Added health check and root endpoints
- Included comprehensive API documentation
- Applied CORS middleware for development
- Updated README with detailed setup and usage instructions
- Applied code formatting with ruff linter
2025-06-20 23:27:38 +00:00

24 lines
519 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()