zlmdb._database¶
Attributes¶
Classes¶
Internal zLMDB configuration element base type. |
|
ZLMDB database access. |
|
Internal zLMDB database slot configuration element. |
Functions¶
|
Whether another process holds the lock LMDB uses to mark this process as a live |
|
Module Contents¶
- class ConfigurationElement(oid: uuid.UUID | None = None, name: str | None = None, description: str | None = None, tags: List[str] | None = None)[source]¶
Bases:
objectInternal zLMDB configuration element base type.
- static parse(value: Dict[str, Any]) ConfigurationElement[source]¶
- class Database(dbpath: str | None = None, maxsize: int = 10485760, readonly: bool = False, lock: bool = True, sync: bool = True, create: bool = True, open_now: bool = True, writemap: bool = False, context: Any = None, log: txaio.interfaces.ILogger | None = None, lib_version: str | None = None)[source]¶
Bases:
objectZLMDB database access.
Objects of this class are generally “light-weight” (cheap to create and destroy), but do manage internal resource such as file descriptors.
To manage these resources in a robust way, this class implements the Python context manager interface.
- __enter__()[source]¶
Enter database runtime context and open the underlying LMDB database environment.
Note
Enter the runtime context related to this object. The with statement will bind this method’s return value to the target(s) specified in the as clause of the statement, if any. [Source](https://docs.python.org/3/reference/datamodel.html#object.__enter__)
Note
A context manager is an object that defines the runtime context to be established when executing a with statement. The context manager handles the entry into, and the exit from, the desired runtime context for the execution of the block of code. Context managers are normally invoked using the with statement (described in section The with statement), but can also be used by directly invoking their methods.” [Source](https://docs.python.org/3/reference/datamodel.html#with-statement-context-managers)
- Returns:
This database instance (in open state).
- __exit__(exc_type, exc_value, traceback)[source]¶
Exit runtime context and close the underlying LMDB database environment.
Note
Exit the runtime context related to this object. The parameters describe the exception that caused the context to be exited. If the context was exited without an exception, all three arguments will be None. [Source](https://docs.python.org/3/reference/datamodel.html#object.__exit__).
- Parameters:
exc_type
exc_value
traceback
- Returns:
- __slots__ = ('log', '_is_temp', '_tempdir', '_dbpath', '_maxsize', '_readonly', '_lock', '_sync', '_create',...[source]¶
- _attach_slot(oid: uuid.UUID, klass: Type[zlmdb._pmap.PersistentMap], marshal: Callable | None = None, parse: Callable | None = None, build: Callable | None = None, cast: Callable | None = None, compress: int | None = None, create: bool = True, name: str | None = None, description: str | None = None)[source]¶
- Parameters:
oid
klass
marshal
parse
build
cast
compress
create
name
description
- Returns:
- attach_table(klass: Type[zlmdb._pmap.PersistentMap])[source]¶
- Parameters:
klass
- Returns:
- begin(write: bool = False, buffers: bool = False, stats: zlmdb._transaction.TransactionStats | None = None) zlmdb._transaction.Transaction[source]¶
- Parameters:
write
buffers
stats
- Returns:
- property lib_version: str | None[source]¶
LMDB format of this database,
"1.0"or"0.9"(Nonebefore it was first opened when nolib_versionwas given).- Returns:
- static open(dbpath: str | None = None, maxsize: int = 10485760, readonly: bool = False, lock: bool = True, sync: bool = True, create: bool = True, open_now: bool = True, writemap: bool = False, context: Any = None, log: txaio.interfaces.ILogger | None = None, lib_version: str | None = None) Database[source]¶
- class Slot(oid: uuid.UUID | None = None, name: str | None = None, description: str | None = None, tags: List[str] | None = None, slot: int | None = None, creator: str | None = None)[source]¶
Bases:
ConfigurationElementInternal zLMDB database slot configuration element.
- _pid_lock_held_by_other(dbpath: str) bool[source]¶
Whether another process holds the lock LMDB uses to mark this process as a live reader: an fcntl lock on the byte at offset = our PID in
lock.mdb. A process with the same PID in another PID namespace (e.g. in another container) holds it for as long as it has the database open (#196).Closing a file descriptor drops all of this process’s fcntl locks on that file. That is safe here only because this process has no environment open on
dbpath(_LMDB_MYPID_ENVS), and the failed one is closed already.