Automated Action cdd4aec842 Build simple todo app with FastAPI and SQLite
- Created FastAPI application with CRUD operations for todos
- Implemented SQLite database with SQLAlchemy ORM
- Added Alembic for database migrations
- Set up CORS middleware for all origins
- Added health check endpoint at /health
- Created comprehensive API documentation
- Formatted code with Ruff linter
- Updated README with project information

Features:
- Create, read, update, delete todos
- Pagination support for listing todos
- Auto-generated OpenAPI documentation at /docs
- Health monitoring endpoint
2025-06-19 21:46:14 +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()