Persistence and Serialization Modules
dbm.ndbm
Wraps an optional NDBM-compatible native library for persistent byte mappings. The underlying implementation and file format vary by platform. Do not assume compatibility with GNU DBM or use an NDBM database concurrently without checking its backend restrictions.
Formal Syntax & Structure
python syntaxpython
import dbm.ndbmReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
import dbm.ndbmfrom tempfile import TemporaryDirectoryfrom pathlib import Pathwith TemporaryDirectory() as folder: path = str(Path(folder)/"store") with dbm.ndbm.open(path, "n") as db: db[b"count"] = b"3" with dbm.ndbm.open(path, "r") as db: print(db[b"count"].decode("ascii"))