Automated Action 8ffce8f5fe Implement todo application with FastAPI and SQLite
- Set up project structure with FastAPI
- Create SQLite database models with SQLAlchemy
- Implement Alembic for migrations
- Create API endpoints for todo operations
- Add health check endpoint
- Update README.md with comprehensive documentation

generated with BackendIM... (backend.im)
2025-05-13 04:46:37 +00:00

26 lines
655 B
Python

from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from app.core.config import settings
# Create directory if it doesn't exist
settings.DB_DIR.mkdir(parents=True, exist_ok=True)
engine = create_engine(
settings.SQLALCHEMY_DATABASE_URL,
connect_args={"check_same_thread": False} # SQLite specific
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
def create_tables():
Base.metadata.create_all(bind=engine)