blob: c465d3937748fe8f12f35ccc030f23b4609a4d0d [file] [log] [blame]
Guido van Rossum571391b1997-04-03 22:41:49 +00001\section{Standard Module \sectcode{anydbm}}
2\stmodindex{anydbm}
3\stmodindex{dumbdbm}
4
5\code{anydbm} is a generic interface to variants of the DBM
6database--DBM, GDBM, or dbhash. If none of these modules is
7installed, the slow-but-simple implementation in \file{dumbdbm.py}
8will be used.
9
10\begin{funcdesc}{open}{filename\optional{\, flag\, mode}}
11Open the database file \var{filename} and return a corresponding object.
12The optional \var{flag} argument can be
13\code{'r'} to open an existing database for reading only,
14\code{'w'} to open an existing database for reading and writing,
15\code{'c'} to create the database if it doesn't exist, or
16\code{'n'}, which will always create a new empty database. If not
17specified, the default value is \code{'r'}.
18
19The optional \var{mode} argument is the \UNIX{} mode of the file, used
20only when the database has to be created. It defaults to octal
21\code{0666}.
22\end{funcdesc}
23
24THe object returned by \code{open()} supports most of the same
25functionality as dictionaries; keys and their corresponding values can
26be stored, retrieved, and deleted, and the \code{has_key()} and
27\code{keys()} methods are available. Keys and values must always be strings.
28
29