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.
This module can be used with the ``classic'' ndbm interface, the BSD DB compatibility interface, or the GNU GDBM compatibility interface. On Unix, the configure script will attempt to locate the appropriate header file to simplify building this module.
The module defines the following:
ndbm
implementation library used.
filename[, flag[, mode]]) |
The optional flag argument must be one of these values:
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 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.