zlmdb._lmdb_vendor.tool

Basic tools for working with LMDB.

copy: Consistent high speed backup an environment.

%prog copy -e source.lmdb target.lmdb

copyfd: Consistent high speed backup an environment to stdout.

%prog copyfd -e source.lmdb > target.lmdb/data.mdb

drop: Delete one or more sub-databases.

%prog drop -e /path/to/db db1

dump: Dump one or more databases to disk in ‘cdbmake’ format.

%prog dump -e /path/to/db [db1=file1.cdbmake db2=file2.cdbmake]

If no databases are given, dumps the main database to ‘main.cdbmake’. With –all, dumps the main database and every named database, each to ‘<name>.cdbmake’.

edit: Add/delete/replace values from a database.
%prog edit –set key=value –set-file key=/path

–add key=value –add-file key=/path/to/file –delete key

get: Read one or more values from a database.

%prog get -e /path/to/db [<key1> [<keyN> [..]]]

readers: Display readers in the lock table

%prog readers -e /path/to/db [-c]

If -c is specified, clear stale readers.

restore: Read one or more database from disk in ‘cdbmake’ format.

%prog restore -e /path/to/db db1=file1.cdbmake db2=file2.cdbmake

The special db name “:main:” may be used to indicate the main DB.

rewrite: Re-create an environment using MDB_APPEND

%prog rewrite -e src.lmdb -E dst.lmdb [<db1> [<dbN> ..]]

If no databases are given, rewrites only the main database.

shell: Open interactive console with ENV set to the open environment.

stat: Print environment statistics.

verify: Offline structural audit of a data file (verify-then-trust).

%prog verify -e /path/to/db # subdir environment %prog verify -s single.mdb # single-file environment

Reads the file as raw bytes without opening it through liblmdb, and checks every invariant the engine’s write paths assume. Exits 0 and prints “verify: OK” if the file is sound; otherwise prints each problem and exits 1. Run this on a file you do not control before trusting it.

warm: Read environment into page cache sequentially.

watch: Show live environment statistics

Attributes

Classes

Functions

_find_diskstat(path)

_get_term_width([default])

_on_sigwinch(*args)

_to_bytes(s)

Given a str, return a bytes instance.

all_dbs_map()

Map the main database and every named database to an output file

cmd_copy(opts, args)

cmd_copyfd(opts, args)

cmd_drop(opts, args)

cmd_dump(opts, args)

cmd_edit(opts, args)

cmd_get(opts, args)

cmd_readers(opts, args)

cmd_restore(opts, args)

cmd_rewrite(opts, args)

cmd_shell(opts, args)

cmd_stat(opts, args)

cmd_verify(opts, args)

Fully verify a data file offline, without opening it through liblmdb.

cmd_warm(opts, args)

cmd_watch(opts, args)

db_map_from_args(args)

delta(hst)

die(fmt, *args) → NoReturn

dump_cursor_to_fp(cursor, fp)

isprint(c)

Return True if the character c can be printed visibly and without

main([argv])

make_parser()

restore_cursor_from_fp(txn, fp, db)

xxd(s)

Return a vaguely /usr/bin/xxd formatted representation of the bytestring

Module Contents

BUF_SIZE = 10485760[source]
DB = None[source]
class DiskStatter(path)[source]
FIELDS = ('reads', 'reads_merged', 'sectors_read', 'read_ms', 'writes', 'writes_merged',...[source]
fp[source]
refresh()[source]
sectors_read: int[source]
sectors_written: int[source]
ENCODING = 'utf-8'[source]
ENV: zlmdb._lmdb_vendor.Environment | None = None[source]
SYS_BLOCK = '/sys/block'[source]
_find_diskstat(path)[source]
_get_term_width(default=(80, 25))[source]
_on_sigwinch(*args)[source]
_to_bytes(s)[source]

Given a str, return a bytes instance.

all_dbs_map()[source]

Map the main database and every named database to an output file named after it, for dump --all.

cmd_copy(opts, args)[source]
cmd_copyfd(opts, args)[source]
cmd_drop(opts, args)[source]
cmd_dump(opts, args)[source]
cmd_edit(opts, args)[source]
cmd_get(opts, args)[source]
cmd_readers(opts, args)[source]
cmd_restore(opts, args)[source]
cmd_rewrite(opts, args)[source]
cmd_shell(opts, args)[source]
cmd_stat(opts, args)[source]
cmd_verify(opts, args)[source]

Fully verify a data file offline, without opening it through liblmdb.

Usage: %prog verify [-e ENV | <path>] [-s]

Reads the file as raw bytes and checks every invariant the LMDB write paths assume (see lmdb/verify.py). Prints “verify: OK” and exits 0 if the file is sound; otherwise prints each problem and exits 1. This is the offline audit for the “verify-then-trust” model: pass a file you do not control through it before opening that file with the engine.

cmd_warm(opts, args)[source]
cmd_watch(opts, args)[source]
db_map_from_args(args)[source]
delta(hst)[source]
die(fmt, *args) → NoReturn[source]
dump_cursor_to_fp(cursor, fp)[source]
isprint(c)[source]

Return True if the character c can be printed visibly and without adversely affecting printing position (e.g. newline).

main(argv=None)[source]
make_parser()[source]
restore_cursor_from_fp(txn, fp, db)[source]
xxd(s)[source]

Return a vaguely /usr/bin/xxd formatted representation of the bytestring s.