Deprecated since version 2.6: The dbhash module has been deprecated for removal in Python 3.0.
The dbhash module provides a function to open databases using the BSD db library. This module mirrors the interface of the other Python database modules that provide access to DBM-style databases. The bsddb module is required to use dbhash.
This module provides an exception and a function:
Open a db database and return the database object. The path argument is the name of the database file.
The flag argument can be:
|Open existing database for reading only (default)
|Open existing database for reading and writing
|Open database for reading and writing, creating it if it doesn’t exist
|Always create a new, empty database, open for reading and writing
For platforms on which the BSD db library supports locking, an 'l' can be appended to indicate that locking should be used.
The optional mode parameter is used to indicate the Unix permission bits that should be set if a new database must be created; this will be masked by the current umask value for the process.
The database objects returned by open() provide the methods common to all the DBM-style databases and mapping objects. The following methods are available in addition to the standard methods.
Returns the key next key/value pair in a database traversal. The following code prints every key in the database db, without having to create a list in memory that contains them all:
for i in xrange(1, len(db)):