2003-07-14 09:12:37 -03:00
|
|
|
\section{\module{dumbdbm} ---
|
2003-07-21 12:30:15 -03:00
|
|
|
Portable DBM implementation}
|
2003-07-14 09:12:37 -03:00
|
|
|
|
2003-07-21 12:30:15 -03:00
|
|
|
\declaremodule{standard}{dumbdbm}
|
|
|
|
\modulesynopsis{Portable implementation of the simple DBM interface.}
|
2003-07-14 09:12:37 -03:00
|
|
|
|
|
|
|
\index{databases}
|
|
|
|
|
2003-07-21 12:30:15 -03:00
|
|
|
\begin{notice}
|
|
|
|
The \module{dumbdbm} module is intended as a last resort fallback for
|
|
|
|
the \refmodule{anydbm} module when no more robust module is available.
|
2003-07-14 09:12:37 -03:00
|
|
|
The \module{dumbdbm} module is not written for speed and is not nearly as
|
2003-07-21 12:30:15 -03:00
|
|
|
heavily used as the other database modules.
|
|
|
|
\end{notice}
|
2003-07-14 09:12:37 -03:00
|
|
|
|
2003-07-21 12:30:15 -03:00
|
|
|
The \module{dumbdbm} module provides a persistent dictionary-like interface
|
2003-07-14 09:12:37 -03:00
|
|
|
which is written entirely in Python. Unlike other modules such as
|
2003-07-21 12:30:15 -03:00
|
|
|
\refmodule{gdbm} and \refmodule{bsddb}, no external library is required. As
|
2003-07-14 09:12:37 -03:00
|
|
|
with other persistent mappings, the keys and values must always be strings.
|
|
|
|
|
|
|
|
The module defines the following:
|
|
|
|
|
|
|
|
\begin{excdesc}{error}
|
|
|
|
Raised on dumbdbm-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 dumbdbm database and return a dumbdbm object. The \var{filename}
|
|
|
|
argument is the basename of the database file (without any specific
|
2003-07-21 12:30:15 -03:00
|
|
|
extensions). When a dumbdbm database is created, files with \file{.dat} and
|
|
|
|
\file{.dir} extensions are created.
|
2003-07-14 09:12:37 -03:00
|
|
|
|
2003-07-21 12:30:15 -03:00
|
|
|
The optional \var{flag} argument is currently ignored; the database is
|
|
|
|
always opened for update, and will be created if it does not exist.
|
2003-07-14 09:12:37 -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
|
2003-07-21 12:30:15 -03:00
|
|
|
\code{0666} (and will be modified by the prevailing umask).
|
|
|
|
\versionchanged[The \var{mode} argument was ignored in earlier
|
|
|
|
versions]{2.2}
|
2003-07-14 09:12:37 -03:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
|
|
|
|
\begin{seealso}
|
|
|
|
\seemodule{anydbm}{Generic interface to \code{dbm}-style databases.}
|
|
|
|
\seemodule{dbm}{Similar interface to the DBM/NDBM library.}
|
|
|
|
\seemodule{gdbm}{Similar interface to the GNU GDBM library.}
|
|
|
|
\seemodule{shelve}{Persistence module which stores non-string data.}
|
|
|
|
\seemodule{whichdb}{Utility module used to determine the type of an
|
|
|
|
existing database.}
|
|
|
|
\end{seealso}
|
2003-07-21 12:30:15 -03:00
|
|
|
|
|
|
|
|
|
|
|
\subsection{Dumbdbm Objects \label{dumbdbm-objects}}
|
|
|
|
|
|
|
|
In addition to the methods provided by the \class{UserDict.DictMixin} class,
|
|
|
|
\class{dumbdbm} objects provide the following methods.
|
|
|
|
|
|
|
|
\begin{methoddesc}{sync}{}
|
|
|
|
Synchronize the on-disk directory and data files. This method is called by
|
|
|
|
the \method{sync} method of \class{Shelve} objects.
|
|
|
|
\end{methoddesc}
|