Files
sound-analyze/services/api/app/db/session.py
Iwwww 1b864228d4 feat(api): add backend
routes and WebSockets
2025-12-26 19:26:06 +03:00

13 lines
453 B
Python

from typing import AsyncGenerator
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
from app.core.config import settings
engine = create_async_engine(settings.DATABASE_URL, echo=False, pool_pre_ping=True)
SessionLocal = async_sessionmaker(engine, expire_on_commit=False, autoflush=False)
async def get_db() -> AsyncGenerator[AsyncSession, None]:
async with SessionLocal() as session:
yield session