Skip to content

db#

Database Connections

get_async_session() async #

Yield an AsyncSession

Used by FastAPI Depends

Source code in zoo/db.py
async def get_async_session() -> AsyncGenerator[AsyncSession, None]:
    """
    Yield an AsyncSession

    Used by FastAPI Depends
    """
    try:
        async with async_session() as session:
            yield session
    finally:
        await session.close()