summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libdbm.tex
blob: 09ce0df0de35a1197e310c09c9f156500c561d2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
\section{\module{dbm} ---
         Simple ``database'' interface}

\declaremodule{builtin}{dbm}
  \platform{UNIX}
\modulesynopsis{The standard ``database'' interface, based on ndbm.}


The \module{dbm} module provides an interface to the \UNIX{}
\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
\method{items()} and \method{values()} methods are not supported.

See also the \refmodule{gdbm}\refbimodindex{gdbm} module, which
provides a similar interface using the GNU GDBM library.

The module defines the following constant and functions:

\begin{excdesc}{error}
Raised on dbm-specific errors, such as I/O errors.
\exception{KeyError} is raised for general mapping errors like
specifying an incorrect key.
\end{excdesc}

\begin{funcdesc}{open}{filename, \optional{flag, \optional{mode}}}
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}.
\end{funcdesc}