Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 1 | \section{Built-in Module \sectcode{dbm}} |
| 2 | \bimodindex{dbm} |
| 3 | |
| 4 | Dbm provides python programs with an interface to the unix \code{ndbm} |
| 5 | database library. Dbm objects are of the mapping type, so they can be |
| 6 | handled just like objects of the built-in \dfn{dictionary} type, |
| 7 | except that keys and values are always strings, and printing a dbm |
| 8 | object doesn't print the keys and values. |
| 9 | |
| 10 | The module defines the following constant and functions: |
| 11 | |
| 12 | \renewcommand{\indexsubitem}{(in module dbm)} |
| 13 | \begin{excdesc}{error} |
| 14 | Raised on dbm-specific errors, such as I/O errors. \code{KeyError} is |
| 15 | raised for general mapping errors like specifying an incorrect key. |
| 16 | \end{excdesc} |
| 17 | |
| 18 | \begin{funcdesc}{open}{filename\, rwmode\, filemode} |
| 19 | Open a dbm database and return a mapping object. \var{filename} is |
| 20 | the name of the database file (without the \file{.dir} or \file{.pag} |
| 21 | extensions), \var{rwmode} is \code{'r'}, \code{'w'} or \code{'rw'} as for |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 22 | \code{open}, and \var{filemode} is the \UNIX{} mode of the file, used only |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 23 | when the database has to be created. |
| 24 | \end{funcdesc} |