acapy_agent.database_manager package
Database manager module with automatic backend registration.
Subpackages
- acapy_agent.database_manager.databases package
- Subpackages
- acapy_agent.database_manager.databases.backends package
- acapy_agent.database_manager.databases.sqlite_normalized package
ConnectionPoolDatabaseErrorDatabaseErrorCodeSqliteConfig- Subpackages
- Submodules
- acapy_agent.database_manager.databases.sqlite_normalized.backend module
- acapy_agent.database_manager.databases.sqlite_normalized.config module
- acapy_agent.database_manager.databases.sqlite_normalized.connection_pool module
- acapy_agent.database_manager.databases.sqlite_normalized.database module
- acapy_agent.database_manager.databases.sqlite_normalized.session module
- Submodules
- acapy_agent.database_manager.databases.errors module
DatabaseErrorDatabaseErrorCodeDatabaseErrorCode.CONNECTION_ERRORDatabaseErrorCode.CONNECTION_POOL_EXHAUSTEDDatabaseErrorCode.DATABASE_NOT_ENCRYPTEDDatabaseErrorCode.DATABASE_NOT_FOUNDDatabaseErrorCode.DEFAULT_PROFILE_NOT_FOUNDDatabaseErrorCode.DUPLICATE_ITEM_ENTRY_ERRORDatabaseErrorCode.PROFILE_ALREADY_EXISTSDatabaseErrorCode.PROFILE_NOT_FOUNDDatabaseErrorCode.PROVISION_ERRORDatabaseErrorCode.QUERY_ERRORDatabaseErrorCode.RECORD_NOT_FOUNDDatabaseErrorCode.UNSUPPORTED_VERSION
- Subpackages
- acapy_agent.database_manager.wql_normalized package
- Subpackages
- Submodules
- acapy_agent.database_manager.wql_normalized.query module
- acapy_agent.database_manager.wql_normalized.tags module
CompareOpConjunctionOpTagNameTagQueryTagQueryEncoderTagQueryEncoder.encode_conj()TagQueryEncoder.encode_conj_clause()TagQueryEncoder.encode_exist()TagQueryEncoder.encode_exist_clause()TagQueryEncoder.encode_in()TagQueryEncoder.encode_in_clause()TagQueryEncoder.encode_name()TagQueryEncoder.encode_op()TagQueryEncoder.encode_op_clause()TagQueryEncoder.encode_query()TagQueryEncoder.encode_value()
query_to_tagquery()
- acapy_agent.database_manager.wql_nosql package
- Subpackages
- Submodules
- acapy_agent.database_manager.wql_nosql.query module
- acapy_agent.database_manager.wql_nosql.tags module
CompareOpConjunctionOpTagNameTagQueryTagQueryEncoderTagQueryEncoder.encode_conj()TagQueryEncoder.encode_conj_clause()TagQueryEncoder.encode_exist()TagQueryEncoder.encode_exist_clause()TagQueryEncoder.encode_in()TagQueryEncoder.encode_in_clause()TagQueryEncoder.encode_name()TagQueryEncoder.encode_op()TagQueryEncoder.encode_op_clause()TagQueryEncoder.encode_query()TagQueryEncoder.encode_value()
query_to_tagquery()
- acapy_agent.database_manager.wql_nosql.test_string_to_tagquery module
TestQueryTestQuery.test_and_exist()TestQuery.test_and_or_not_complex_case_parse()TestQuery.test_and_or_not_complex_case_to_string()TestQuery.test_and_with_multiple_eq_parse()TestQuery.test_and_with_multiple_eq_to_string()TestQuery.test_and_with_multiple_gt_parse()TestQuery.test_and_with_multiple_gt_to_string()TestQuery.test_and_with_multiple_gte_parse()TestQuery.test_and_with_multiple_gte_to_string()TestQuery.test_and_with_multiple_in_parse()TestQuery.test_and_with_multiple_in_to_string()TestQuery.test_and_with_multiple_like_parse()TestQuery.test_and_with_multiple_like_to_string()TestQuery.test_and_with_multiple_lt_parse()TestQuery.test_and_with_multiple_lt_to_string()TestQuery.test_and_with_multiple_lte_parse()TestQuery.test_and_with_multiple_lte_to_string()TestQuery.test_and_with_multiple_mixed_parse()TestQuery.test_and_with_multiple_mixed_to_string()TestQuery.test_and_with_multiple_neq_parse()TestQuery.test_and_with_multiple_neq_to_string()TestQuery.test_and_with_multiple_not_eq_parse()TestQuery.test_and_with_multiple_not_eq_to_string()TestQuery.test_and_with_one_eq_parse()TestQuery.test_and_with_one_eq_to_string()TestQuery.test_and_with_one_gt_parse()TestQuery.test_and_with_one_gt_to_string()TestQuery.test_and_with_one_gte_parse()TestQuery.test_and_with_one_gte_to_string()TestQuery.test_and_with_one_in_parse()TestQuery.test_and_with_one_in_to_string()TestQuery.test_and_with_one_like_parse()TestQuery.test_and_with_one_like_to_string()TestQuery.test_and_with_one_lt_parse()TestQuery.test_and_with_one_lt_to_string()TestQuery.test_and_with_one_lte_parse()TestQuery.test_and_with_one_lte_to_string()TestQuery.test_and_with_one_neq_parse()TestQuery.test_and_with_one_neq_to_string()TestQuery.test_and_with_one_not_eq_parse()TestQuery.test_and_with_one_not_eq_to_string()TestQuery.test_exist_parse_array()TestQuery.test_exist_parse_string()TestQuery.test_not_with_one_eq_parse()TestQuery.test_not_with_one_eq_to_string()TestQuery.test_not_with_one_gt_parse()TestQuery.test_not_with_one_gt_to_string()TestQuery.test_not_with_one_gte_parse()TestQuery.test_not_with_one_gte_to_string()TestQuery.test_not_with_one_in_parse()TestQuery.test_not_with_one_in_to_string()TestQuery.test_not_with_one_like_parse()TestQuery.test_not_with_one_like_to_string()TestQuery.test_not_with_one_lt_parse()TestQuery.test_not_with_one_lt_to_string()TestQuery.test_not_with_one_lte_parse()TestQuery.test_not_with_one_lte_to_string()TestQuery.test_not_with_one_neq_parse()TestQuery.test_not_with_one_neq_to_string()TestQuery.test_old_format()TestQuery.test_old_format_empty()TestQuery.test_old_format_with_nulls()TestQuery.test_optimise_and()TestQuery.test_optimise_or()TestQuery.test_optimise_several_nested_and()TestQuery.test_optimise_several_nested_or()TestQuery.test_optimise_single_nested_and()TestQuery.test_optimise_single_nested_or()TestQuery.test_or_with_multiple_eq_parse()TestQuery.test_or_with_multiple_eq_to_string()TestQuery.test_or_with_multiple_gt_parse()TestQuery.test_or_with_multiple_gt_to_string()TestQuery.test_or_with_multiple_gte_parse()TestQuery.test_or_with_multiple_gte_to_string()TestQuery.test_or_with_multiple_in_parse()TestQuery.test_or_with_multiple_in_to_string()TestQuery.test_or_with_multiple_like_parse()TestQuery.test_or_with_multiple_like_to_string()TestQuery.test_or_with_multiple_lt_parse()TestQuery.test_or_with_multiple_lt_to_string()TestQuery.test_or_with_multiple_lte_parse()TestQuery.test_or_with_multiple_lte_to_string()TestQuery.test_or_with_multiple_mixed_parse()TestQuery.test_or_with_multiple_mixed_to_string()TestQuery.test_or_with_multiple_neq_parse()TestQuery.test_or_with_multiple_neq_to_string()TestQuery.test_or_with_multiple_not_eq_parse()TestQuery.test_or_with_multiple_not_eq_to_string()TestQuery.test_or_with_one_eq_parse()TestQuery.test_or_with_one_eq_to_string()TestQuery.test_or_with_one_gt_parse()TestQuery.test_or_with_one_gt_to_string()TestQuery.test_or_with_one_gte_parse()TestQuery.test_or_with_one_gte_to_string()TestQuery.test_or_with_one_in_parse()TestQuery.test_or_with_one_in_to_string()TestQuery.test_or_with_one_like_parse()TestQuery.test_or_with_one_like_to_string()TestQuery.test_or_with_one_lt_parse()TestQuery.test_or_with_one_lt_to_string()TestQuery.test_or_with_one_lte_parse()TestQuery.test_or_with_one_lte_to_string()TestQuery.test_or_with_one_neq_parse()TestQuery.test_or_with_one_neq_to_string()TestQuery.test_or_with_one_not_eq_parse()TestQuery.test_or_with_one_not_eq_to_string()TestQuery.test_short_and_with_multiple_eq_parse()TestQuery.test_simple_operator_empty_and_to_string()TestQuery.test_simple_operator_empty_json_parse()TestQuery.test_simple_operator_empty_not_parse()TestQuery.test_simple_operator_empty_or_parse()TestQuery.test_simple_operator_eq_parse()TestQuery.test_simple_operator_eq_to_string()TestQuery.test_simple_operator_eq_with_tilde_parse()TestQuery.test_simple_operator_eq_with_tilde_to_string()TestQuery.test_simple_operator_explicit_empty_and_parse()TestQuery.test_simple_operator_gt_parse()TestQuery.test_simple_operator_gt_plaintext_to_string()TestQuery.test_simple_operator_gte_parse()TestQuery.test_simple_operator_gte_to_string()TestQuery.test_simple_operator_in_multimply_to_string()TestQuery.test_simple_operator_in_multiple_parse()TestQuery.test_simple_operator_in_parse()TestQuery.test_simple_operator_in_to_string()TestQuery.test_simple_operator_like_parse()TestQuery.test_simple_operator_like_to_string()TestQuery.test_simple_operator_lt_parse()TestQuery.test_simple_operator_lt_to_string()TestQuery.test_simple_operator_lte_parse()TestQuery.test_simple_operator_lte_to_string()TestQuery.test_simple_operator_neq_parse()TestQuery.test_simple_operator_neq_to_string()
random_string()
Submodules
acapy_agent.database_manager.category_registry module
Category registry for database managers.
- acapy_agent.database_manager.category_registry.get_release(release_number: str, db_type: str = 'sqlite') Tuple[dict, dict, dict][source]
Retrieve handlers and schemas for a given release number and database type.
acapy_agent.database_manager.db_errors module
Unified database error helpers across Askar and DBStore.
Provides a common tuple of exception types and grouped error-code sets so business logic can remain agnostic to the underlying storage backend.
- class acapy_agent.database_manager.db_errors.DBCode[source]
Bases:
objectUnified code groups: use in membership checks.
Example
- try:
repo.save(record)
- except DBError as err:
- if err.code not in DBCode.DUPLICATE:
raise
- DUPLICATE: FrozenSet[aries_askar.AskarErrorCode | DBStoreErrorCode] = frozenset({DBStoreErrorCode.DUPLICATE, aries_askar.AskarErrorCode.DUPLICATE})
- NOT_FOUND: FrozenSet[aries_askar.AskarErrorCode | DBStoreErrorCode] = frozenset({DBStoreErrorCode.NOT_FOUND, aries_askar.AskarErrorCode.NOT_FOUND})
acapy_agent.database_manager.db_types module
Database types and data structures for database manager.
- class acapy_agent.database_manager.db_types.Entry(category: str, name: str, value: str | bytes, tags: dict)[source]
Bases:
objectA single result from a store query.
- property category: str
Get the entry category.
- property name: str
Get the entry name.
- property raw_value: memoryview
Get the entry value as raw bytes.
- property tags: dict
Get the entry tags.
- property value: str
Get the entry value.
- property value_json: dict
Get the entry value parsed as JSON.
- class acapy_agent.database_manager.db_types.EntryList(entries: Sequence[Entry], length: int = None)[source]
Bases:
objectA list of Entry objects.
- property handle
Get dummy handle for compatibility.
- class acapy_agent.database_manager.db_types.EntryOperation(*values)[source]
Bases:
EnumEnumeration of database entry operations.
- INSERT = 0
- REMOVE = 2
- REPLACE = 1
- class acapy_agent.database_manager.db_types.IterEntryList(list: EntryList)[source]
Bases:
objectIterator for EntryList.
- class acapy_agent.database_manager.db_types.KeyAlg(*values)[source]
Bases:
EnumEnumeration of supported key algorithms.
- A128CBC_HS256 = 'a128cbchs256'
- A128GCM = 'a128gcm'
- A128KW = 'a128kw'
- A256CBC_HS512 = 'a256cbchs512'
- A256GCM = 'a256gcm'
- A256KW = 'a256kw'
- BLS12_381_G1 = 'bls12381g1'
- BLS12_381_G1G2 = 'bls12381g1g2'
- BLS12_381_G2 = 'bls12381g2'
- C20P = 'c20p'
- ED25519 = 'ed25519'
- K256 = 'k256'
- P256 = 'p256'
- X25519 = 'x25519'
- XC20P = 'xc20p'
acapy_agent.database_manager.dbstore module
Database store module for managing different database backends.
- class acapy_agent.database_manager.dbstore.DBOpenSession(db: AbstractDatabaseStore, profile: str | None, is_txn: bool, release_number: str)[source]
Bases:
objectDatabase open session class.
- property is_transaction: bool
Perform the action.
- class acapy_agent.database_manager.dbstore.DBStore(db: AbstractDatabaseStore, uri: str, release_number: str = 'release_0')[source]
Bases:
objectDatabase store class.
- property handle
Perform the action.
- async classmethod open(uri: str, key_method: str = None, pass_key: str = None, *, profile: str = None, schema_migration: bool | None = None, target_schema_release_number: str | None = None, config: dict | None = None) DBStore[source]
Perform the action.
- async classmethod provision(uri: str, key_method: str = None, pass_key: str = None, *, profile: str = None, recreate: bool = False, release_number: str = 'release_0', schema_config: str | None = None, config: dict | None = None) DBStore[source]
Provision a new database store with specified release and schema.
- property release_number: str
Perform the action.
- async classmethod remove(uri: str, release_number: str = 'release_0', config: dict | None = None) bool[source]
Remove the database store.
- scan(category: str, tag_filter: str | dict = None, offset: int = None, limit: int = None, profile: str = None, order_by: str | None = None, descending: bool = False) Scan[source]
Scan the database for entries matching the criteria.
- scan_keyset(category: str, tag_filter: str | dict = None, last_id: int | None = None, limit: int = None, profile: str = None, order_by: str | None = None, descending: bool = False) ScanKeyset[source]
Scan the database using keyset pagination.
- session(profile: str = None) DBOpenSession[source]
Perform the action.
- transaction(profile: str = None) DBOpenSession[source]
Perform the action.
- property uri: str
Perform the action.
- class acapy_agent.database_manager.dbstore.DBStoreSession(db_session: AbstractDatabaseSession, is_txn: bool)[source]
Bases:
objectDatabase store session class.
- async fetch(category: str, name: str, *, for_update: bool = False) Entry | None[source]
Perform the action.
- async fetch_all(category: str, tag_filter: str | dict = None, limit: int = None, for_update: bool = False, order_by: str | None = None, descending: bool = False) EntryList[source]
Perform the action.
- property handle
Get a unique identifier for the session.
- async insert(category: str, name: str, value: str | bytes = None, tags: dict = None, expiry_ms: int = None, value_json=None) None[source]
Perform the action.
- property is_transaction: bool
Check if the session is a transaction.
- class acapy_agent.database_manager.dbstore.Scan(store: DBStore, profile: str | None, category: str | bytes, tag_filter: str | dict = None, offset: int = None, limit: int = None, order_by: str | None = None, descending: bool = False)[source]
Bases:
AsyncIteratorAsync iterator for database scanning.
- class acapy_agent.database_manager.dbstore.ScanKeyset(store: DBStore, profile: str | None, category: str | bytes, tag_filter: str | dict = None, last_id: int | None = None, limit: int = None, order_by: str | None = None, descending: bool = False)[source]
Bases:
AsyncIteratorKeyset-based scan iterator.
- acapy_agent.database_manager.dbstore.register_backend(db_type: str, backend: DatabaseBackend)[source]
Register a backend for a given database type.
acapy_agent.database_manager.error module
Error classes for database management.
- exception acapy_agent.database_manager.error.DBStoreError(code: DBStoreErrorCode, message: str, extra: str = None)[source]
Bases:
ExceptionDatabase store error.
acapy_agent.database_manager.interfaces module
Module docstring.
- class acapy_agent.database_manager.interfaces.AbstractDatabaseSession[source]
Bases:
ABCAbstract base class for database session implementations.
- abstractmethod async count(category: str, tag_filter: str | dict = None) int[source]
Count entries.
- abstractmethod async fetch(category: str, name: str, for_update: bool = False) Entry | None[source]
Fetch a single entry.
- abstractmethod async fetch_all(category: str, tag_filter: str | dict = None, limit: int = None, for_update: bool = False) Sequence[Entry][source]
Fetch all matching entries.
- abstractmethod async insert(category: str, name: str, value: str | bytes = None, tags: dict = None, expiry_ms: int = None, value_json=None)[source]
Insert a new entry.
- abstractmethod async remove_all(category: str, tag_filter: str | dict = None) int[source]
Remove all matching entries.
- class acapy_agent.database_manager.interfaces.AbstractDatabaseStore[source]
Bases:
ABCAbstract base class for database store implementations.
- abstractmethod async rekey(key_method: str = None, pass_key: str = None)[source]
Re-key the database.
- abstractmethod scan(profile: str | None, category: str, tag_filter: str | dict = None, offset: int = None, limit: int = None) Generator[Entry, None, None][source]
Scan database entries.
- abstractmethod session(profile: str = None, release_number: str = 'release_0') AbstractDatabaseSession[source]
Create a new database session with the specified release number.
- Parameters:
profile – Optional profile name.
release_number – Release number to use (e.g., ‘release_0’). Defaults to ‘release_0’.
- Returns:
The session instance.
- Return type:
- abstractmethod transaction(profile: str = None, release_number: str = 'release_0') AbstractDatabaseSession[source]
Create a new database transaction with the specified release number.
- Parameters:
profile – Optional profile name.
release_number – Release number to use (e.g., ‘release_0’). Defaults to ‘release_0’.
- Returns:
The transaction instance.
- Return type:
- class acapy_agent.database_manager.interfaces.DatabaseBackend[source]
Bases:
ABCAbstract base class for database backends.
- abstractmethod open(uri, key_method, pass_key, profile, release_number: str = 'release_0')[source]
Open an existing database with the specified release number.
- Parameters:
uri – The database URI.
key_method – Optional key method for encryption.
pass_key – Optional encryption key.
profile – Optional profile name.
release_number – Release number to use (e.g., ‘release_0’). Defaults to ‘release_0’.
- abstractmethod provision(uri, key_method, pass_key, profile, recreate, release_number: str = 'release_0')[source]
Provision a new database with the specified release number.
- Parameters:
uri – The database URI.
key_method – Optional key method for encryption.
pass_key – Optional encryption key.
profile – Optional profile name.
recreate – If True, recreate the database.
release_number – Release number to use (e.g., ‘release_0’). Defaults to ‘release_0’.
acapy_agent.database_manager.key module
Handling of Key instances.
- class acapy_agent.database_manager.key.Key(handle: Any)[source]
Bases:
objectAn active key or keypair instance.
- aead_decrypt(ciphertext: bytes = None, *, nonce: bytes | None = None, aad: bytes | None = None) bytes[source]
Return placeholder decrypted data.
- aead_encrypt(plaintext: bytes = None, *, nonce: bytes | None = None, aad: bytes | None = None) str[source]
Return a placeholder for encrypted data.
- property ephemeral: bool
Return a placeholder ephemeral flag since bindings is unavailable.
- classmethod from_jwk(jwk: dict | str | bytes) Key[source]
Raise an error as JWK-based key creation requires bindings.
- classmethod from_public_bytes(alg: str | KeyAlg, public: bytes) Key[source]
Raise an error as public-based key creation requires bindings.
- classmethod from_secret_bytes(alg: str | KeyAlg, secret: bytes) Key[source]
Raise an error as secret-based key creation requires bindings.
- classmethod from_seed(alg: str | KeyAlg, seed: str | bytes, *, method: str | SeedMethod = None) Key[source]
Raise an error as seed-based key creation requires bindings.
- classmethod generate(alg: str | KeyAlg, *, ephemeral: bool = False) Key[source]
Raise an error as key generation requires bindings.
- property handle: Any
Accessor for the key handle.
- key_exchange(alg: str | KeyAlg, pk: Key) Key[source]
Raise an error as key exchange requires bindings.
- sign_message(message: str | bytes, sig_type: str = None) bytes[source]
Raise an error as signing requires bindings.