1998-04-04 03:23:21 -04:00
|
|
|
\section{Built-in Module \module{dbm}}
|
1997-07-17 13:34:52 -03:00
|
|
|
\label{module-dbm}
|
1994-01-01 21:22:07 -04:00
|
|
|
\bimodindex{dbm}
|
|
|
|
|
1996-12-13 18:04:31 -04:00
|
|
|
The \code{dbm} module provides an interface to the \UNIX{}
|
1995-07-07 19:55:57 -03:00
|
|
|
\code{(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
|
|
|
|
\code{items()} and \code{values()} methods are not supported.
|
|
|
|
|
|
|
|
See also the \code{gdbm} module, which provides a similar interface
|
|
|
|
using the GNU GDBM library.
|
1997-12-16 00:08:24 -04:00
|
|
|
\refbimodindex{gdbm}
|
1994-01-01 21:22:07 -04:00
|
|
|
|
|
|
|
The module defines the following constant and functions:
|
|
|
|
|
|
|
|
\begin{excdesc}{error}
|
|
|
|
Raised on dbm-specific errors, such as I/O errors. \code{KeyError} is
|
|
|
|
raised for general mapping errors like specifying an incorrect key.
|
|
|
|
\end{excdesc}
|
|
|
|
|
1998-03-17 02:33:25 -04:00
|
|
|
\begin{funcdesc}{open}{filename, \optional{flag, \optional{mode}}}
|
1995-07-07 19:55:57 -03:00
|
|
|
Open a dbm database and return a dbm object. The \var{filename}
|
|
|
|
argument is the name of the database file (without the \file{.dir} or
|
|
|
|
\file{.pag} extensions).
|
|
|
|
|
|
|
|
The optional \var{flag} argument can be
|
|
|
|
\code{'r'} (to open an existing database for reading only --- default),
|
|
|
|
\code{'w'} (to open an existing database for reading and writing),
|
|
|
|
\code{'c'} (which creates the database if it doesn't exist), or
|
|
|
|
\code{'n'} (which always creates a new empty database).
|
|
|
|
|
|
|
|
The optional \var{mode} argument is the \UNIX{} mode of the file, used
|
|
|
|
only when the database has to be created. It defaults to octal
|
|
|
|
\code{0666}.
|
1994-01-01 21:22:07 -04:00
|
|
|
\end{funcdesc}
|