Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 1 | :mod:`dbm` --- Interfaces to Unix "databases" |
| 2 | ============================================= |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 3 | |
| 4 | .. module:: dbm |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 5 | :synopsis: Interfaces to various Unix "database" formats. |
| 6 | |
| 7 | :mod:`dbm` is a generic interface to variants of the DBM database --- |
Georg Brandl | ac958ce | 2010-07-29 14:46:07 +0000 | [diff] [blame] | 8 | :mod:`dbm.gnu` or :mod:`dbm.ndbm`. If none of these modules is installed, the |
| 9 | slow-but-simple implementation in module :mod:`dbm.dumb` will be used. There |
| 10 | is a `third party interface <http://www.jcea.es/programacion/pybsddb.htm>`_ to |
Georg Brandl | bb19015 | 2010-07-31 21:41:42 +0000 | [diff] [blame] | 11 | the Oracle Berkeley DB. |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 12 | |
| 13 | |
| 14 | .. exception:: error |
| 15 | |
| 16 | A tuple containing the exceptions that can be raised by each of the supported |
| 17 | modules, with a unique exception also named :exc:`dbm.error` as the first |
| 18 | item --- the latter is used when :exc:`dbm.error` is raised. |
| 19 | |
| 20 | |
| 21 | .. function:: whichdb(filename) |
| 22 | |
Georg Brandl | e8b0d61 | 2010-12-04 09:04:04 +0000 | [diff] [blame] | 23 | This function attempts to guess which of the several simple database modules |
Georg Brandl | ac958ce | 2010-07-29 14:46:07 +0000 | [diff] [blame] | 24 | available --- :mod:`dbm.gnu`, :mod:`dbm.ndbm` or :mod:`dbm.dumb` --- should |
| 25 | be used to open a given file. |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 26 | |
| 27 | Returns one of the following values: ``None`` if the file can't be opened |
| 28 | because it's unreadable or doesn't exist; the empty string (``''``) if the |
| 29 | file's format can't be guessed; or a string containing the required module |
| 30 | name, such as ``'dbm.ndbm'`` or ``'dbm.gnu'``. |
| 31 | |
| 32 | |
Éric Araujo | 5c1a0c9 | 2011-04-20 19:11:12 +0200 | [diff] [blame] | 33 | .. function:: open(file, flag='r', mode=0o666) |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 34 | |
Éric Araujo | 5c1a0c9 | 2011-04-20 19:11:12 +0200 | [diff] [blame] | 35 | Open the database file *file* and return a corresponding object. |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 36 | |
| 37 | If the database file already exists, the :func:`whichdb` function is used to |
| 38 | determine its type and the appropriate module is used; if it does not exist, |
| 39 | the first module listed above that can be imported is used. |
| 40 | |
Georg Brandl | 1a04058 | 2009-05-25 21:15:01 +0000 | [diff] [blame] | 41 | The optional *flag* argument can be: |
| 42 | |
| 43 | +---------+-------------------------------------------+ |
| 44 | | Value | Meaning | |
| 45 | +=========+===========================================+ |
| 46 | | ``'r'`` | Open existing database for reading only | |
| 47 | | | (default) | |
| 48 | +---------+-------------------------------------------+ |
| 49 | | ``'w'`` | Open existing database for reading and | |
| 50 | | | writing | |
| 51 | +---------+-------------------------------------------+ |
| 52 | | ``'c'`` | Open database for reading and writing, | |
| 53 | | | creating it if it doesn't exist | |
| 54 | +---------+-------------------------------------------+ |
| 55 | | ``'n'`` | Always create a new, empty database, open | |
| 56 | | | for reading and writing | |
| 57 | +---------+-------------------------------------------+ |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 58 | |
| 59 | The optional *mode* argument is the Unix mode of the file, used only when the |
| 60 | database has to be created. It defaults to octal ``0o666`` (and will be |
| 61 | modified by the prevailing umask). |
| 62 | |
| 63 | |
Georg Brandl | d9e833c | 2010-12-04 09:14:36 +0000 | [diff] [blame] | 64 | The object returned by :func:`.open` supports the same basic functionality as |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 65 | dictionaries; keys and their corresponding values can be stored, retrieved, and |
| 66 | deleted, and the :keyword:`in` operator and the :meth:`keys` method are |
Georg Brandl | d9e833c | 2010-12-04 09:14:36 +0000 | [diff] [blame] | 67 | available, as well as :meth:`get` and :meth:`setdefault`. |
| 68 | |
| 69 | .. versionchanged:: 3.2 |
| 70 | :meth:`get` and :meth:`setdefault` are now available in all database modules. |
| 71 | |
| 72 | Key and values are always stored as bytes. This means that when |
Brett Cannon | 7317c1e | 2008-11-25 19:19:17 +0000 | [diff] [blame] | 73 | strings are used they are implicitly converted to the default encoding before |
| 74 | being stored. |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 75 | |
Nick Coghlan | c610aba | 2013-11-17 15:59:51 +1000 | [diff] [blame] | 76 | These objects also support being used in a :keyword:`with` statement, which |
| 77 | will automatically close them when done. |
| 78 | |
| 79 | .. versionchanged:: 3.4 |
| 80 | Added native support for the context management protocol to the objects |
| 81 | returned by :func:`.open`. |
| 82 | |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 83 | The following example records some hostnames and a corresponding title, and |
| 84 | then prints out the contents of the database:: |
| 85 | |
| 86 | import dbm |
| 87 | |
| 88 | # Open database, creating it if necessary. |
Nick Coghlan | c610aba | 2013-11-17 15:59:51 +1000 | [diff] [blame] | 89 | with dbm.open('cache', 'c') as db: |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 90 | |
Nick Coghlan | c610aba | 2013-11-17 15:59:51 +1000 | [diff] [blame] | 91 | # Record some values |
| 92 | db[b'hello'] = b'there' |
| 93 | db['www.python.org'] = 'Python Website' |
| 94 | db['www.cnn.com'] = 'Cable News Network' |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 95 | |
Nick Coghlan | c610aba | 2013-11-17 15:59:51 +1000 | [diff] [blame] | 96 | # Note that the keys are considered bytes now. |
| 97 | assert db[b'www.python.org'] == b'Python Website' |
| 98 | # Notice how the value is now in bytes. |
| 99 | assert db['www.cnn.com'] == b'Cable News Network' |
Brett Cannon | 7317c1e | 2008-11-25 19:19:17 +0000 | [diff] [blame] | 100 | |
Nick Coghlan | c610aba | 2013-11-17 15:59:51 +1000 | [diff] [blame] | 101 | # Often-used methods of the dict interface work too. |
| 102 | print(db.get('python.org', b'not present')) |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 103 | |
Nick Coghlan | c610aba | 2013-11-17 15:59:51 +1000 | [diff] [blame] | 104 | # Storing a non-string key or value will raise an exception (most |
| 105 | # likely a TypeError). |
| 106 | db['www.yahoo.com'] = 4 |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 107 | |
Nick Coghlan | c610aba | 2013-11-17 15:59:51 +1000 | [diff] [blame] | 108 | # db is automatically closed when leaving the with statement. |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 109 | |
| 110 | |
| 111 | .. seealso:: |
| 112 | |
| 113 | Module :mod:`shelve` |
| 114 | Persistence module which stores non-string data. |
| 115 | |
| 116 | |
| 117 | The individual submodules are described in the following sections. |
| 118 | |
| 119 | |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 120 | :mod:`dbm.gnu` --- GNU's reinterpretation of dbm |
| 121 | ------------------------------------------------ |
| 122 | |
| 123 | .. module:: dbm.gnu |
| 124 | :platform: Unix |
| 125 | :synopsis: GNU's reinterpretation of dbm. |
| 126 | |
| 127 | |
| 128 | This module is quite similar to the :mod:`dbm` module, but uses the GNU library |
| 129 | ``gdbm`` instead to provide some additional functionality. Please note that the |
Brett Cannon | 7317c1e | 2008-11-25 19:19:17 +0000 | [diff] [blame] | 130 | file formats created by :mod:`dbm.gnu` and :mod:`dbm.ndbm` are incompatible. |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 131 | |
| 132 | The :mod:`dbm.gnu` module provides an interface to the GNU DBM library. |
Brett Cannon | 7317c1e | 2008-11-25 19:19:17 +0000 | [diff] [blame] | 133 | ``dbm.gnu.gdbm`` objects behave like mappings (dictionaries), except that keys and |
| 134 | values are always converted to bytes before storing. Printing a ``gdbm`` |
| 135 | object doesn't print the |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 136 | keys and values, and the :meth:`items` and :meth:`values` methods are not |
| 137 | supported. |
| 138 | |
| 139 | .. exception:: error |
| 140 | |
Brett Cannon | 7317c1e | 2008-11-25 19:19:17 +0000 | [diff] [blame] | 141 | Raised on :mod:`dbm.gnu`-specific errors, such as I/O errors. :exc:`KeyError` is |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 142 | raised for general mapping errors like specifying an incorrect key. |
| 143 | |
| 144 | |
Georg Brandl | c2a4f4f | 2009-04-10 09:03:43 +0000 | [diff] [blame] | 145 | .. function:: open(filename[, flag[, mode]]) |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 146 | |
| 147 | Open a ``gdbm`` database and return a :class:`gdbm` object. The *filename* |
| 148 | argument is the name of the database file. |
| 149 | |
| 150 | The optional *flag* argument can be: |
| 151 | |
| 152 | +---------+-------------------------------------------+ |
| 153 | | Value | Meaning | |
| 154 | +=========+===========================================+ |
| 155 | | ``'r'`` | Open existing database for reading only | |
| 156 | | | (default) | |
| 157 | +---------+-------------------------------------------+ |
| 158 | | ``'w'`` | Open existing database for reading and | |
| 159 | | | writing | |
| 160 | +---------+-------------------------------------------+ |
| 161 | | ``'c'`` | Open database for reading and writing, | |
| 162 | | | creating it if it doesn't exist | |
| 163 | +---------+-------------------------------------------+ |
| 164 | | ``'n'`` | Always create a new, empty database, open | |
| 165 | | | for reading and writing | |
| 166 | +---------+-------------------------------------------+ |
| 167 | |
| 168 | The following additional characters may be appended to the flag to control |
| 169 | how the database is opened: |
| 170 | |
| 171 | +---------+--------------------------------------------+ |
| 172 | | Value | Meaning | |
| 173 | +=========+============================================+ |
| 174 | | ``'f'`` | Open the database in fast mode. Writes | |
| 175 | | | to the database will not be synchronized. | |
| 176 | +---------+--------------------------------------------+ |
| 177 | | ``'s'`` | Synchronized mode. This will cause changes | |
| 178 | | | to the database to be immediately written | |
| 179 | | | to the file. | |
| 180 | +---------+--------------------------------------------+ |
| 181 | | ``'u'`` | Do not lock database. | |
| 182 | +---------+--------------------------------------------+ |
| 183 | |
| 184 | Not all flags are valid for all versions of ``gdbm``. The module constant |
| 185 | :const:`open_flags` is a string of supported flag characters. The exception |
| 186 | :exc:`error` is raised if an invalid flag is specified. |
| 187 | |
| 188 | The optional *mode* argument is the Unix mode of the file, used only when the |
Georg Brandl | f4a4123 | 2008-05-26 17:55:52 +0000 | [diff] [blame] | 189 | database has to be created. It defaults to octal ``0o666``. |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 190 | |
| 191 | In addition to the dictionary-like methods, ``gdbm`` objects have the |
| 192 | following methods: |
| 193 | |
| 194 | .. method:: gdbm.firstkey() |
| 195 | |
| 196 | It's possible to loop over every key in the database using this method and the |
| 197 | :meth:`nextkey` method. The traversal is ordered by ``gdbm``'s internal |
| 198 | hash values, and won't be sorted by the key values. This method returns |
| 199 | the starting key. |
| 200 | |
| 201 | .. method:: gdbm.nextkey(key) |
| 202 | |
| 203 | Returns the key that follows *key* in the traversal. The following code prints |
| 204 | every key in the database ``db``, without having to create a list in memory that |
| 205 | contains them all:: |
| 206 | |
| 207 | k = db.firstkey() |
| 208 | while k != None: |
| 209 | print(k) |
| 210 | k = db.nextkey(k) |
| 211 | |
| 212 | .. method:: gdbm.reorganize() |
| 213 | |
| 214 | If you have carried out a lot of deletions and would like to shrink the space |
| 215 | used by the ``gdbm`` file, this routine will reorganize the database. ``gdbm`` |
Brett Cannon | 7317c1e | 2008-11-25 19:19:17 +0000 | [diff] [blame] | 216 | objects will not shorten the length of a database file except by using this |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 217 | reorganization; otherwise, deleted file space will be kept and reused as new |
| 218 | (key, value) pairs are added. |
| 219 | |
| 220 | .. method:: gdbm.sync() |
| 221 | |
| 222 | When the database has been opened in fast mode, this method forces any |
| 223 | unwritten data to be written to the disk. |
| 224 | |
Jesus Cea | ac4b7f7 | 2014-06-25 13:05:31 +0200 | [diff] [blame] | 225 | .. method:: gdbm.close() |
| 226 | |
| 227 | Close the ``gdbm`` database. |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 228 | |
| 229 | :mod:`dbm.ndbm` --- Interface based on ndbm |
| 230 | ------------------------------------------- |
| 231 | |
| 232 | .. module:: dbm.ndbm |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 233 | :platform: Unix |
| 234 | :synopsis: The standard "database" interface, based on ndbm. |
| 235 | |
| 236 | |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 237 | The :mod:`dbm.ndbm` module provides an interface to the Unix "(n)dbm" library. |
| 238 | Dbm objects behave like mappings (dictionaries), except that keys and values are |
Brett Cannon | 7317c1e | 2008-11-25 19:19:17 +0000 | [diff] [blame] | 239 | always stored as bytes. Printing a ``dbm`` object doesn't print the keys and |
| 240 | values, and the :meth:`items` and :meth:`values` methods are not supported. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 241 | |
Georg Brandl | ac958ce | 2010-07-29 14:46:07 +0000 | [diff] [blame] | 242 | This module can be used with the "classic" ndbm interface or the GNU GDBM |
| 243 | compatibility interface. On Unix, the :program:`configure` script will attempt |
| 244 | to locate the appropriate header file to simplify building this module. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 245 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 246 | .. exception:: error |
| 247 | |
Brett Cannon | 7317c1e | 2008-11-25 19:19:17 +0000 | [diff] [blame] | 248 | Raised on :mod:`dbm.ndbm`-specific errors, such as I/O errors. :exc:`KeyError` is raised |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 249 | for general mapping errors like specifying an incorrect key. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 250 | |
| 251 | |
| 252 | .. data:: library |
| 253 | |
| 254 | Name of the ``ndbm`` implementation library used. |
| 255 | |
| 256 | |
| 257 | .. function:: open(filename[, flag[, mode]]) |
| 258 | |
Jesus Cea | ac4b7f7 | 2014-06-25 13:05:31 +0200 | [diff] [blame] | 259 | Open a dbm database and return a ``ndbm`` object. The *filename* argument is the |
Georg Brandl | ac958ce | 2010-07-29 14:46:07 +0000 | [diff] [blame] | 260 | name of the database file (without the :file:`.dir` or :file:`.pag` extensions). |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 261 | |
| 262 | The optional *flag* argument must be one of these values: |
| 263 | |
| 264 | +---------+-------------------------------------------+ |
| 265 | | Value | Meaning | |
| 266 | +=========+===========================================+ |
| 267 | | ``'r'`` | Open existing database for reading only | |
| 268 | | | (default) | |
| 269 | +---------+-------------------------------------------+ |
| 270 | | ``'w'`` | Open existing database for reading and | |
| 271 | | | writing | |
| 272 | +---------+-------------------------------------------+ |
| 273 | | ``'c'`` | Open database for reading and writing, | |
| 274 | | | creating it if it doesn't exist | |
| 275 | +---------+-------------------------------------------+ |
| 276 | | ``'n'`` | Always create a new, empty database, open | |
| 277 | | | for reading and writing | |
| 278 | +---------+-------------------------------------------+ |
| 279 | |
| 280 | The optional *mode* argument is the Unix mode of the file, used only when the |
Georg Brandl | f4a4123 | 2008-05-26 17:55:52 +0000 | [diff] [blame] | 281 | database has to be created. It defaults to octal ``0o666`` (and will be |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 282 | modified by the prevailing umask). |
| 283 | |
Jesus Cea | ac4b7f7 | 2014-06-25 13:05:31 +0200 | [diff] [blame] | 284 | In addition to the dictionary-like methods, ``ndbm`` objects |
| 285 | provide the following method: |
| 286 | |
| 287 | .. method:: ndbm.close() |
| 288 | |
| 289 | Close the ``ndbm`` database. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 290 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 291 | |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 292 | :mod:`dbm.dumb` --- Portable DBM implementation |
| 293 | ----------------------------------------------- |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 294 | |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 295 | .. module:: dbm.dumb |
| 296 | :synopsis: Portable implementation of the simple DBM interface. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 297 | |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 298 | .. index:: single: databases |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 299 | |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 300 | .. note:: |
| 301 | |
| 302 | The :mod:`dbm.dumb` module is intended as a last resort fallback for the |
Brett Cannon | 7317c1e | 2008-11-25 19:19:17 +0000 | [diff] [blame] | 303 | :mod:`dbm` module when a more robust module is not available. The :mod:`dbm.dumb` |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 304 | module is not written for speed and is not nearly as heavily used as the other |
| 305 | database modules. |
| 306 | |
| 307 | The :mod:`dbm.dumb` module provides a persistent dictionary-like interface which |
Brett Cannon | 7317c1e | 2008-11-25 19:19:17 +0000 | [diff] [blame] | 308 | is written entirely in Python. Unlike other modules such as :mod:`dbm.gnu` no |
Benjamin Peterson | 9a46cab | 2008-09-08 02:49:30 +0000 | [diff] [blame] | 309 | external library is required. As with other persistent mappings, the keys and |
Brett Cannon | 7317c1e | 2008-11-25 19:19:17 +0000 | [diff] [blame] | 310 | values are always stored as bytes. |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 311 | |
| 312 | The module defines the following: |
| 313 | |
| 314 | |
| 315 | .. exception:: error |
| 316 | |
Brett Cannon | 7317c1e | 2008-11-25 19:19:17 +0000 | [diff] [blame] | 317 | Raised on :mod:`dbm.dumb`-specific errors, such as I/O errors. :exc:`KeyError` is |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 318 | raised for general mapping errors like specifying an incorrect key. |
| 319 | |
| 320 | |
| 321 | .. function:: open(filename[, flag[, mode]]) |
| 322 | |
Brett Cannon | 7317c1e | 2008-11-25 19:19:17 +0000 | [diff] [blame] | 323 | Open a ``dumbdbm`` database and return a dumbdbm object. The *filename* argument is |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 324 | the basename of the database file (without any specific extensions). When a |
| 325 | dumbdbm database is created, files with :file:`.dat` and :file:`.dir` extensions |
| 326 | are created. |
| 327 | |
Serhiy Storchaka | b398d33 | 2014-06-10 21:16:00 +0300 | [diff] [blame] | 328 | The optional *flag* argument supports only the semantics of ``'c'`` |
| 329 | and ``'n'`` values. Other values will default to database being always |
| 330 | opened for update, and will be created if it does not exist. |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 331 | |
| 332 | The optional *mode* argument is the Unix mode of the file, used only when the |
| 333 | database has to be created. It defaults to octal ``0o666`` (and will be modified |
| 334 | by the prevailing umask). |
| 335 | |
Serhiy Storchaka | b398d33 | 2014-06-10 21:16:00 +0300 | [diff] [blame] | 336 | .. versionchanged:: 3.5 |
| 337 | :func:`.open` always creates a new database when the flag has the value |
| 338 | ``'n'``. |
| 339 | |
Serhiy Storchaka | bfdcd43 | 2013-10-13 23:09:14 +0300 | [diff] [blame] | 340 | In addition to the methods provided by the |
| 341 | :class:`collections.abc.MutableMapping` class, :class:`dumbdbm` objects |
Jesus Cea | ac4b7f7 | 2014-06-25 13:05:31 +0200 | [diff] [blame] | 342 | provide the following methods: |
Georg Brandl | 0a7ac7d | 2008-05-26 10:29:35 +0000 | [diff] [blame] | 343 | |
| 344 | .. method:: dumbdbm.sync() |
| 345 | |
| 346 | Synchronize the on-disk directory and data files. This method is called |
| 347 | by the :meth:`Shelve.sync` method. |
Jesus Cea | ac4b7f7 | 2014-06-25 13:05:31 +0200 | [diff] [blame] | 348 | |
| 349 | .. method:: dumbdbm.close() |
| 350 | |
| 351 | Close the ``dumbdbm`` database. |
| 352 | |