Automated Action 6f0470e475 Implement Bible Quiz App API with FastAPI and SQLite
- Setup project structure with FastAPI app
- Create SQLAlchemy models for categories, questions, quizzes, and results
- Implement API endpoints for all CRUD operations
- Set up Alembic migrations for database schema management
- Add comprehensive documentation in README.md
2025-06-05 10:31:02 +00:00

25 lines
627 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
# Ensure database directory exists
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)
Base = declarative_base()
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()