zlmdb._database

Attributes

Classes

ConfigurationElement

Internal zLMDB configuration element base type.

Database

ZLMDB database access.

Schema

Slot

Internal zLMDB database slot configuration element.

Functions

qual(→ str)

Module Contents

class ConfigurationElement(oid: uuid.UUID | None = None, name: str | None = None, description: str | None = None, tags: List[str] | None = None)[source]

Bases: object

Internal zLMDB configuration element base type.

__eq__(other: Any) bool[source]
__ne__(other: Any) bool[source]
__slots__ = ('_oid', '_name', '_description', '_tags')[source]
__str__() str[source]
_description = None[source]
_name = None[source]
_oid = None[source]
_tags = None[source]
property description: str | None[source]
marshal() Dict[str, Any][source]
property name: str | None[source]
property oid: uuid.UUID | None[source]
static parse(value: Dict[str, Any]) ConfigurationElement[source]
property tags: List[str] | None[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)[source]

Bases: object

ZLMDB 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:

_cache_slots()[source]
Returns:

_context = None[source]
_create = True[source]
_env: zlmdb.lmdb.Environment | None = None[source]
_get_free_slot() int[source]
Returns:

_get_slots(cached=True) Dict[uuid.UUID, Slot][source]
Parameters:

cached

Returns:

_lock = True[source]
_maxsize = 10485760[source]
_open_now = True[source]
_readonly = False[source]
_set_slot(slot_index: int, slot: Slot | None)[source]
Parameters:
  • slot_index

  • slot

Returns:

_slots: Dict[uuid.UUID, Slot] | None = None[source]
_slots_by_index: Dict[uuid.UUID, int] | None = None[source]
_sync = True[source]
_writemap = False[source]
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:

config() Dict[str, Any][source]
Returns:

property context[source]

return:

property dbpath: str | None[source]

return:

property is_open: bool[source]

return:

property is_readonly: bool[source]

return:

property is_sync: bool[source]

return:

property is_writemap: bool[source]

return:

property maxsize: int[source]

return:

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) Database[source]
static scratch(dbpath: str)[source]
Parameters:

dbpath

Returns:

stats(include_slots: bool = False) Dict[str, Any][source]
Parameters:

include_slots

Returns:

sync(force: bool = False)[source]
Parameters:

force

Returns:

KV_TYPE_TO_CLASS[source]
class Schema(meta, slots, slots_byname)[source]

Bases: object

abstractmethod __delitem__(name)[source]
__getitem__(name)[source]
__iter__()[source]
__len__()[source]
abstractmethod __setitem__(name, value)[source]
__str__()[source]
_meta[source]
_slots[source]
_slots_byname[source]
static parse(filename, klassmap=KV_TYPE_TO_CLASS)[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: ConfigurationElement

Internal zLMDB database slot configuration element.

__slots__ = ('_slot', '_creator')[source]
__str__() str[source]
_creator = None[source]
_slot = None[source]
property creator: str | None[source]
marshal() Dict[str, Any][source]
static parse(data: Dict[str, Any]) Slot[source]
property slot: int | None[source]
_LMDB_MYPID_ENVS: Dict[str, Tuple[Database, int]][source]
qual(clazz: type) str[source]