Automated Action f55cad6274 Create Todo application with FastAPI
- Set up project structure with FastAPI
- Implement Todo model and database connection
- Set up Alembic for database migrations
- Create CRUD API endpoints for Todo management
- Add health endpoint for application monitoring
- Update README with project documentation

generated with BackendIM... (backend.im)
2025-05-14 01:20:30 +00:00

23 lines
521 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()