dbm
dbm
module provides an interface to the UNIX
(n)dbm
library. Dbm objects behave like mappings
(dictionaries), except that keys and values are always strings.
Printing a dbm object doesn't print the keys and values, and the
items()
and values()
methods are not supported.
See also the gdbm
module, which provides a similar interface
using the GNU GDBM library.
The module defines the following constant and functions:
KeyError
is
raised for general mapping errors like specifying an incorrect key.
The optional flag argument can be
'r'
(to open an existing database for reading only --- default),
'w'
(to open an existing database for reading and writing),
'c'
(which creates the database if it doesn't exist), or
'n'
(which always creates a new empty database).
The optional mode argument is the UNIX mode of the file, used
only when the database has to be created. It defaults to octal
0666
.