dbm.ndbm.library

dbm.ndbm.library Name of the ndbm implementation library used.

dbm.ndbm.error

exception dbm.ndbm.error Raised on dbm.ndbm-specific errors, such as I/O errors. KeyError is raised for general mapping errors like specifying an incorrect key.

dbm.gnu.open()

dbm.gnu.open(filename[, flag[, mode]]) Open a gdbm database and return a gdbm object. The filename argument is the name of the database file. The optional flag argument can be: Value Meaning 'r' Open existing database for reading only (default) 'w' Open existing database for reading and writing 'c' Open database for reading and writing, creating it if it doesn’t exist 'n' Always create a new, empty database, open for reading and writing The following additional characters may be appended t

dbm.gnu.gdbm.sync()

gdbm.sync() When the database has been opened in fast mode, this method forces any unwritten data to be written to the disk.

dbm.gnu.gdbm.reorganize()

gdbm.reorganize() If you have carried out a lot of deletions and would like to shrink the space used by the gdbm file, this routine will reorganize the database. gdbm objects will not shorten the length of a database file except by using this reorganization; otherwise, deleted file space will be kept and reused as new (key, value) pairs are added.

dbm.gnu.gdbm.nextkey()

gdbm.nextkey(key) Returns the key that follows key in the traversal. The following code prints every key in the database db, without having to create a list in memory that contains them all: k = db.firstkey() while k != None: print(k) k = db.nextkey(k)

dbm.gnu.gdbm.firstkey()

gdbm.firstkey() It’s possible to loop over every key in the database using this method and the nextkey() method. The traversal is ordered by gdbm‘s internal hash values, and won’t be sorted by the key values. This method returns the starting key.

dbm.gnu.gdbm.close()

gdbm.close() Close the gdbm database.

dbm.gnu.error

exception dbm.gnu.error Raised on dbm.gnu-specific errors, such as I/O errors. KeyError is raised for general mapping errors like specifying an incorrect key.

dbm.error

exception dbm.error A tuple containing the exceptions that can be raised by each of the supported modules, with a unique exception also named dbm.error as the first item — the latter is used when dbm.error is raised.