blob: 4e91ac93dfd11dd2bb74a8fdb4993963683682e2 [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +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
Georg Brandl116aa622007-08-15 14:28:22 +000046
47.. seealso::
48
49 Module :mod:`anydbm`
50 Generic interface to ``dbm``\ -style databases.
51
52 Module :mod:`dbm`
53 Similar interface to the DBM/NDBM library.
54
55 Module :mod:`gdbm`
56 Similar interface to the GNU GDBM library.
57
58 Module :mod:`shelve`
59 Persistence module which stores non-string data.
60
61 Module :mod:`whichdb`
62 Utility module used to determine the type of an existing database.
63
64
65.. _dumbdbm-objects:
66
67Dumbdbm Objects
68---------------
69
70In addition to the methods provided by the :class:`UserDict.DictMixin` class,
71:class:`dumbdbm` objects provide the following methods.
72
73
74.. method:: dumbdbm.sync()
75
76 Synchronize the on-disk directory and data files. This method is called by the
77 :meth:`sync` method of :class:`Shelve` objects.
78