Store¶
This module provides a SQLAlchemy-backed implementation of Litestar’s
Store protocol. Register a
SQLAlchemyStore under the "sessions" store name to back Litestar’s
server-side session middleware with your SQLAlchemy database.
Store Model Mixin¶
SQLAlchemy Store¶
- class advanced_alchemy.extensions.litestar.store.SQLAlchemyStore[source]¶
Bases:
NamespacedStore,Generic[SQLAlchemyConfigT]SQLAlchemy based, thread and process safe asynchronous key/value store.
Supports both synchronous and asynchronous SQLAlchemy configurations.
- __init__(config, model=StoreModelMixin, namespace=Empty)[source]¶
Initialize
SQLAlchemyStore.- Parameters:
config¶ – An instance of
SQLAlchemyAsyncConfigorSQLAlchemySyncConfig.model¶ – The SQLAlchemy model to use for storing data. Defaults to
StoreItem.namespace¶ – A virtual namespace for keys. If not given, defaults to
LITESTAR. Namespacing can be explicitly disabled by passingNone. This will makedelete_all()unavailable.
- async delete_all()[source]¶
Delete all values in the namespace. Handles both sync and async backends.
- with_namespace(namespace)[source]¶
Return a new
SQLAlchemyStorewith a nested virtual key namespace.- Return type:
SQLAlchemyStore[TypeVar(SQLAlchemyConfigT, bound=Union[SQLAlchemyAsyncConfig,SQLAlchemySyncConfig])]- Parameters:
namespace (str)