Debian Codegraph @

cpython27/Doc/library/dumbdbm.rst

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