blob: f353b5e931c9900a18ee751f50daa78526a9e895 [file] [log] [blame]
Guido van Rossumb69e0951994-08-08 08:03:24 +00001\section{Built-in Module \sectcode{gdbm}}
2\bimodindex{gdbm}
3
4Gdbm provides python programs with an interface to the GNU \code{gdbm}
5database library. Gdbm objects are of the mapping type, so they can be
6handled just like objects of the built-in \dfn{dictionary} type,
7except that keys and values are always strings, and printing a gdbm
8object doesn't print the keys and values.
9
10The module is based on the Dbm module, modified to use GDBM instead.
11
12The module defines the following constant and functions:
13
14\renewcommand{\indexsubitem}{(in module gdbm)}
15\begin{excdesc}{error}
16Raised on gdbm-specific errors, such as I/O errors. \code{KeyError} is
17raised for general mapping errors like specifying an incorrect key.
18\end{excdesc}
19
20\begin{funcdesc}{open}{filename\, rwmode\, filemode}
Guido van Rossum96628a91995-04-10 11:34:00 +000021Open a gdbm database and return a mapping object. \var{filename} is
Guido van Rossumb69e0951994-08-08 08:03:24 +000022the name of the database file, \var{rwmode} is \code{'r'}, \code{'w'},
23\code{'c'}, or \code{'n'} for reader, writer (this also gives read
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000024access), create (writer, but create the database if it doesn't already
Guido van Rossum96628a91995-04-10 11:34:00 +000025exist) and newdb (which will always create a new database). Only one
26writer may open a gdbm file and many readers may open the file. Readers
27and writers cannot open the gdbm file at the same time. Note that the
28\code{GDBM_FAST} mode of opening the database is not supported.
29\var{filemode} is the \UNIX\ mode of the file, used only when a
30database is created (but to be supplied at all times).
Guido van Rossumb69e0951994-08-08 08:03:24 +000031\end{funcdesc}