Files
language-llm/backend/app/database.py
Dennis Thiessen 1406c95fea
All checks were successful
Deploy FluentGerman.ai / deploy (push) Successful in 50s
changed db engine to mysql
2026-02-12 22:11:41 +01:00

25 lines
697 B
Python

"""FluentGerman.ai — Database setup (async MySQL)."""
from collections.abc import AsyncGenerator
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
from sqlalchemy.orm import DeclarativeBase
from app.config import get_settings
engine = create_async_engine(
get_settings().database_url,
echo=get_settings().debug,
pool_recycle=3600, # Reconnect before MySQL's wait_timeout (default 8h)
)
async_session = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
class Base(DeclarativeBase):
pass
async def get_db() -> AsyncGenerator[AsyncSession, None]:
async with async_session() as session:
yield session