Availability: Unix.
The 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:
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
.
See Also:
dbm
-style databases.