dohdbm module

Implements a dictionary-like database with a degree of persistence.

On open, we read the database into a dictionary. We mutate the dictionary in memory. Then on close, we write the dictionary back to disk.

Has the advantage of being in Pure Python, so it works on about any Python interpreter one cares to consider.

class dohdbm.Dohdbm(filename, flag='r', mode=437, backend_open=<class 'bufsock.rawio'>)[source]

Bases: object

A class implementing a simple database.

close()[source]

Close a database: sync it to disk and mark it closed.

items()[source]

Return the items, AKA the key-value pairs, in the database.

keys()[source]

Return the keys in the database.

sync()[source]

Flush the database to disk.

exception dohdbm.error[source]

Bases: Exception

An exception to raise when we have problems.

dohdbm.open(filename, flag='rb', mode=438, backend_open=<class 'bufsock.rawio'>)[source]

Open a dohdbm database.

dohdbm.safe_rename(backup_filename, regular_filename)[source]

Rename backup_filename to regular_filename.

dohdbm.string_to_binary(string)[source]

Convert a text string (or binary string type) to a binary string type.

dohdbm.touch(filename)[source]

Just update the timestamp on an existing file, or create a file that doesn’t yet exist.