mentat.services.sqlstorage module
Database storage abstraction layer. The current implementation is based on the awesome SQLAlchemy library.
Warning
Current implementation is for optimalization purposes using some advanced schema features provided by the PostgreSQL database and thus no other engines are currently supported.
- class mentat.services.sqlstorage.RetryingQuery(entities: Sequence[_ColumnsClauseArgument[Any]], session: Optional[Session] = None)[source]
Bases:
Query
An override of SQLAlchemy’s Query class, allowing for recovery from a lost DB connection.
- session: Session
- class mentat.services.sqlstorage.StorageService(**enginecfg)[source]
Bases:
object
Proxy object for working with persistent SQL storages. Maintains and provides access to database engine, session maker and session proxies.
- property session
- class mentat.services.sqlstorage.StorageServiceManager(core_config, updates=None)[source]
Bases:
object
Class representing a custom _StorageServiceManager_ capable of understanding and parsing Mentat system core configurations and enabling easy access to preconfigured database collections via indirrect handles (identifiers).
- mentat.services.sqlstorage.close()[source]
Close database connection on
mentat.services.sqlstorage.StorageService
instance from module level manager.
- mentat.services.sqlstorage.init(core_config, updates=None)[source]
(Re-)Initialize
mentat.services.sqlstorage.StorageServiceManager
instance at module level and store the refence within module.- Parameters
core_config (dict) – Mentat core configuration structure.
updates (dict) – Optional configuration updates (same structure as
core_config
).
- mentat.services.sqlstorage.manager()[source]
Obtain reference to
mentat.services.sqlstorage.StorageServiceManager
instance stored at module level.- Returns
Storage service manager reference.
- Return type
- mentat.services.sqlstorage.service()[source]
Obtain reference to
mentat.services.sqlstorage.StorageService
instance from module level manager.- Returns
Storage service reference.
- Return type