/Doc/library/dumbdbm.rst

http://unladen-swallow.googlecode.com/ · ReStructuredText · 84 lines · 53 code · 31 blank · 0 comment · 0 complexity · 593c68dc528bfdc032ea54a0207f0a0b MD5 · raw file

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