1 \section{\module{dbm
} ---
2 Simple ``database'' interface
}
4 \declaremodule{builtin
}{dbm
}
6 \modulesynopsis{The standard ``database'' interface, based on ndbm.
}
9 The
\module{dbm
} module provides an interface to the
\UNIX{}
10 \code{(n)dbm
} library. Dbm objects behave like mappings
11 (dictionaries), except that keys and values are always strings.
12 Printing a dbm object doesn't print the keys and values, and the
13 \method{items()
} and
\method{values()
} methods are not supported.
15 See also the
\refmodule{gdbm
}\refbimodindex{gdbm
} module, which
16 provides a similar interface using the GNU GDBM library.
18 The module defines the following constant and functions:
20 \begin{excdesc
}{error
}
21 Raised on dbm-specific errors, such as I/O errors.
22 \exception{KeyError
} is raised for general mapping errors like
23 specifying an incorrect key.
26 \begin{funcdesc
}{open
}{filename,
\optional{flag,
\optional{mode
}}}
27 Open a dbm database and return a dbm object. The
\var{filename
}
28 argument is the name of the database file (without the
\file{.dir
} or
29 \file{.pag
} extensions).
31 The optional
\var{flag
} argument can be
32 \code{'r'
} (to open an existing database for reading only --- default),
33 \code{'w'
} (to open an existing database for reading and writing),
34 \code{'c'
} (which creates the database if it doesn't exist), or
35 \code{'n'
} (which always creates a new empty database).
37 The optional
\var{mode
} argument is the
\UNIX{} mode of the file, used
38 only when the database has to be created. It defaults to octal
44 \seemodule{anydbm
}{Generic interface to
\code{dbm
}-style databases.
}
45 \seemodule{whichdb
}{Utility module used to determine the type of an