tasklert-api / build /lib /core /database.py
hashir-qt's picture
initial deploy
507973e
Raw History Blame Contribute Delete
482 Bytes
from typing import AsyncGenerator
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
from .config import settings
engine = create_async_engine(
settings.database_url,
echo=settings.debug,
pool_pre_ping=True,
)
async_session = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
async def get_session() -> AsyncGenerator[AsyncSession, None]:
async with async_session() as session:
yield session