← All notes

Python dbm: a generic interface to Unix database formats

Answer: dbm is a generic interface to variants of the DBM database.

Opening a file

Available backends include sqlite3, gnu, and ndbm.

If none of those modules are installed, the slow-but-simple implementation in dbm.dumb is used.

whichdb attempts to guess which of the several simple database modules created a file.

The default open flag is r, which opens an existing database for reading only.

How values are stored

Keys and values are always stored as bytes.

There is a third party interface to the Oracle Berkeley DB.

sqlite3, gnu, and dumb provide a reorganize method that can reclaim unused disk space.

These objects also support being used in a with statement.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, dbm — Interfaces to Unix databases; CPython, dbm documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, dbm — Interfaces to Unix databases; CPython, dbm documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:0924b565

iinventedlight. 2026. "Python dbm: a generic interface to Unix database formats." iinventedlight Library, iil:note:0924b565, version of 2026-11-24. https://iinventedlight.com/library/notes/python-dbm/. License: CC-BY-4.0.

@misc{iil_note_0924b565,
  author = {{iinventedlight}},
  title = {{Python dbm: a generic interface to Unix database formats}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-24},
  url = {https://iinventedlight.com/library/notes/python-dbm/},
  note = {Permanent ID iil:note:0924b565. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-dbm.md.