DBM-Style Databases
Python provides a number of DBM-style database interfaces
- Key-based databases that store arbitrary strings.
- Similar to shelve, but can't store arbitrary objects (strings only)
- Examples: dbm, gdbm, bsddb
Example:
import dbm
d = dbm.open("database","r")
d["foo"] = "bar" # Store a value
s = d["spam"] # Retrieve a value
del d["name"] # Delete a value
d.close() # Close the database
Comments
- The availability of DBM modules depends on optional libraries and may vary.
- Don't use these if you should really be using a relational database (e.g., MySQL).
|