Automated Action a054c1c20d Add simple todo app with FastAPI and SQLite
- Created FastAPI application with CRUD endpoints for todos
- Set up SQLAlchemy with SQLite database
- Created database models and Pydantic schemas
- Added Alembic for database migrations
- Added health check endpoint
- Updated README with project information

generated with BackendIM... (backend.im)
2025-05-12 22:59:07 +00:00

26 lines
631 B
Python

from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from pathlib import Path
# Create database directory
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)
Base = declarative_base()
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()