database.db#
Module Contents#
Classes#
Class responsible for managing the database session using sqlalchemy.ext.asyncio.AsyncSession. |
Functions#
Asynchronously gets the database session as an async generator yielding an AsyncSession. |
Data#
API#
- class database.db.DatabaseSessionManager(url: str)#
Class responsible for managing the database session using sqlalchemy.ext.asyncio.AsyncSession.
- Parameters:
url (str) – The URL for the PostgreSQL database.
Initialization
- async session()#
Context manager method to acquire and yield an asynchronous database session. Handles rollback on exception and ensures session closure.
- Returns:
An asynchronous database session.
- Return type:
AsyncSession
- database.db.sessionmanager = 'DatabaseSessionManager(...)'#
- async database.db.get_db() AsyncGenerator[sqlalchemy.ext.asyncio.AsyncSession, None]#
Asynchronously gets the database session as an async generator yielding an AsyncSession.