Skip to main content

get_db

Provides a database session generator that yields a Session object and ensures it is properly closed after use.

def get_db() - > Generator[Session, None, None]

Provides a transactional database session for executing queries and ensures the session is closed after use.

Returns

TypeDescription
Generator[Session, None, None]A SQLAlchemy session generator that yields a database connection for the duration of the context.