blob: 3db9fda7ce70877ad57ae6eb006f019606de7c69 [file] [log] [blame]
Georg Brandl8ec7f652007-08-15 14:28:01 +00001
2:mod:`dumbdbm` --- Portable DBM implementation
3==============================================
4
5.. module:: dumbdbm
6 :synopsis: Portable implementation of the simple DBM interface.
7
8
9.. index:: single: databases
10
11.. note::
12
13 The :mod:`dumbdbm` module is intended as a last resort fallback for the
14 :mod:`anydbm` module when no more robust module is available. The :mod:`dumbdbm`
15 module is not written for speed and is not nearly as heavily used as the other
16 database modules.
17
18The :mod:`dumbdbm` module provides a persistent dictionary-like interface which
19is written entirely in Python. Unlike other modules such as :mod:`gdbm` and
20:mod:`bsddb`, no external library is required. As with other persistent
21mappings, the keys and values must always be strings.
22
23The module defines the following:
24
25
26.. exception:: error
27
28 Raised on dumbdbm-specific errors, such as I/O errors. :exc:`KeyError` is
29 raised for general mapping errors like specifying an incorrect key.
30
31
32.. function:: open(filename[, flag[, mode]])
33
34 Open a dumbdbm database and return a dumbdbm object. The *filename* argument is
35 the basename of the database file (without any specific extensions). When a
36 dumbdbm database is created, files with :file:`.dat` and :file:`.dir` extensions
37 are created.
38
39 The optional *flag* argument is currently ignored; the database is always opened
40 for update, and will be created if it does not exist.
41
42 The optional *mode* argument is the Unix mode of the file, used only when the
43 database has to be created. It defaults to octal ``0666`` (and will be modified
44 by the prevailing umask).
45
46 .. versionchanged:: 2.2
47 The *mode* argument was ignored in earlier versions.
48
49
50.. seealso::
51
52 Module :mod:`anydbm`
53 Generic interface to ``dbm``\ -style databases.
54
55 Module :mod:`dbm`
56 Similar interface to the DBM/NDBM library.
57
58 Module :mod:`gdbm`
59 Similar interface to the GNU GDBM library.
60
61 Module :mod:`shelve`
62 Persistence module which stores non-string data.
63
64 Module :mod:`whichdb`
65 Utility module used to determine the type of an existing database.
66
67
68.. _dumbdbm-objects:
69
70Dumbdbm Objects
71---------------
72
73In addition to the methods provided by the :class:`UserDict.DictMixin` class,
74:class:`dumbdbm` objects provide the following methods.
75
76
77.. method:: dumbdbm.sync()
78
79 Synchronize the on-disk directory and data files. This method is called by the
80 :meth:`sync` method of :class:`Shelve` objects.
81