The anydbm module
This module provides a unified interface to the simple database drivers supported by Python.
When you open an existing database, the module uses whichdb to figure out what driver to use. When you create a new database, it checks for dbhash, gdbm, dbm, or dumbdbm, in that order.
Example: Using the anydbm module
# File: anydbm-example-1.py import anydbm db = anydbm.open("database", "c") db["1"] = "one" db["2"] = "two" db["3"] = "three" db.close() db = anydbm.open("database", "r") for key in db.keys(): print repr(key), repr(db[key])
'2' 'two' '3' 'three' '1' 'one'
