db
Low-level Database Connection & Session Management.
Provides a context manager to create a new SQLAlchemy session and a decorator to provide a session to a function. This module is designed for managing the database connection in the EleanorAI Framework backend.
Note
SQLAlchemy engine documentation is available here.
Example
Functions
create_rdbms_session
Creates a new session and yields it as a context manager.
The session is automatically committed if no exceptions occur during the execution of the code block. If an exception occurs, the session is rolled back and the exception is re-raised. Finally, the session is closed.
Warning
A commit()
is executed on the session if no exceptions occur during
processing. This effectively enables auto-commit for all managed sessions
regardless of RDBMS backend / driver settings.
Yields:
-
SASession
(Session
) –The created session.
Raises:
-
Exception
–If an exception occurs during the execution of the code block.