Automated Action b5638b4c86 Add Simple Todo Application with FastAPI and SQLite
- Create project structure with FastAPI setup
- Implement Todo model with SQLAlchemy
- Set up database migrations with Alembic
- Create CRUD API endpoints for Todo items
- Add health endpoint for application monitoring
- Update README with documentation

generated with BackendIM... (backend.im)
2025-05-13 05:10:03 +00:00

23 lines
558 B
Python

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from app.core.config import settings
# Create database directory if it doesn't exist
settings.DB_DIR.mkdir(parents=True, exist_ok=True)
SQLALCHEMY_DATABASE_URL = f"sqlite:///{settings.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()