1998-08-10 16:42:37 -03:00
|
|
|
\section{\module{dbm} ---
|
1999-02-19 20:14:17 -04:00
|
|
|
Simple ``database'' interface}
|
1998-07-23 14:59:49 -03:00
|
|
|
|
1999-02-19 20:14:17 -04:00
|
|
|
\declaremodule{builtin}{dbm}
|
1999-03-02 13:03:42 -04:00
|
|
|
\platform{Unix}
|
1998-07-23 14:59:49 -03:00
|
|
|
\modulesynopsis{The standard ``database'' interface, based on ndbm.}
|
|
|
|
|
1994-01-01 21:22:07 -04:00
|
|
|
|
1999-02-19 20:14:17 -04:00
|
|
|
The \module{dbm} module provides an interface to the \UNIX{}
|
2000-09-15 18:31:31 -03:00
|
|
|
(\code{n})\code{dbm} library. Dbm objects behave like mappings
|
1995-07-07 19:55:57 -03:00
|
|
|
(dictionaries), except that keys and values are always strings.
|
|
|
|
Printing a dbm object doesn't print the keys and values, and the
|
1999-03-02 12:37:17 -04:00
|
|
|
\method{items()} and \method{values()} methods are not supported.
|
1995-07-07 19:55:57 -03:00
|
|
|
|
2000-09-15 18:31:31 -03:00
|
|
|
This module can be used with the ``classic'' ndbm interface, the BSD
|
|
|
|
DB compatibility interface, or the GNU GDBM compatibility interface.
|
|
|
|
On \UNIX, the \program{configure} script will attempt to locate the
|
|
|
|
appropriate header file to simplify building this module.
|
1994-01-01 21:22:07 -04:00
|
|
|
|
2000-09-15 18:31:31 -03:00
|
|
|
The module defines the following:
|
1994-01-01 21:22:07 -04:00
|
|
|
|
|
|
|
\begin{excdesc}{error}
|
1999-02-19 20:14:17 -04:00
|
|
|
Raised on dbm-specific errors, such as I/O errors.
|
|
|
|
\exception{KeyError} is raised for general mapping errors like
|
|
|
|
specifying an incorrect key.
|
1994-01-01 21:22:07 -04:00
|
|
|
\end{excdesc}
|
|
|
|
|
2000-09-15 18:31:31 -03:00
|
|
|
\begin{datadesc}{library}
|
|
|
|
Name of the \code{ndbm} implementation library used.
|
|
|
|
\end{datadesc}
|
|
|
|
|
|
|
|
\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
|
2000-09-15 18:31:31 -03:00
|
|
|
\file{.pag} extensions; note that the BSD DB implementation of the
|
|
|
|
interface will append the extension \file{.db} and only create one
|
|
|
|
file).
|
|
|
|
|
|
|
|
The optional \var{flag} argument must be one of these values:
|
1995-07-07 19:55:57 -03:00
|
|
|
|
2000-09-15 18:31:31 -03:00
|
|
|
\begin{tableii}{c|l}{code}{Value}{Meaning}
|
|
|
|
\lineii{'r'}{Open existing database for reading only (default)}
|
|
|
|
\lineii{'w'}{Open existing database for reading and writing}
|
|
|
|
\lineii{'c'}{Open database for reading and writing, creating it if
|
|
|
|
it doesn't exist}
|
|
|
|
\lineii{'n'}{Always create a new, empty database, open for reading
|
|
|
|
and writing}
|
|
|
|
\end{tableii}
|
1995-07-07 19:55:57 -03:00
|
|
|
|
|
|
|
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}
|
1999-04-05 19:18:12 -03:00
|
|
|
|
|
|
|
|
|
|
|
\begin{seealso}
|
|
|
|
\seemodule{anydbm}{Generic interface to \code{dbm}-style databases.}
|
2000-09-15 18:31:31 -03:00
|
|
|
\seemodule{gdbm}{Similar interface to the GNU GDBM library.}
|
1999-04-05 19:18:12 -03:00
|
|
|
\seemodule{whichdb}{Utility module used to determine the type of an
|
|
|
|
existing database.}
|
|
|
|
\end{seealso}
|