Availability: Unix, Windows.
The bsddb module provides an interface to the Berkeley DB library. Users can create hash, btree or record based library files using the appropriate open call. Bsddb objects behave generally like dictionaries. Keys and values must be strings, however, so to use other objects as keys or to store other kinds of objects the user must serialize them somehow, typically using marshal.dumps or pickle.dumps.
Starting with Python 2.3 the bsddb module requires the Berkeley DB library version 3.1 or later (it is known to work with 3.1 thru 4.1 at the time of this writing).
See Also:
The following is a description of the legacy bsddb interface compatible with the old python bsddb module. For details about the more modern Db and DbEnv object oriented interface see the above mentioned pybsddb URL.
The bsddb module defines the following functions that create objects that access the appropriate type of Berkeley DB file. The first two arguments of each function are the same. For ease of portability, only the first two arguments should be used in most instances.
filename[, flag[, mode[, bsize[, ffactor[, nelem[, cachesize[, hash[, lorder]]]]]]]]) |
None
as the
filename. The optional
flag identifies the mode used to open the file. It may be
"r" (read only), "w" (read-write),
"c" (read-write - create if necessary; the default) or
"n" (read-write - truncate to zero length). The other
arguments are rarely used and are just passed to the low-level
dbopen() function. Consult the Berkeley DB documentation
for their use and interpretation.
filename[, flag[, mode[, btflags[, cachesize[, maxkeypage[, minkeypage[, psize[, lorder]]]]]]]]) |
Open the btree format file named filename. Files never intended
to be preserved on disk may be created by passing None
as the
filename. The optional
flag identifies the mode used to open the file. It may be
"r" (read only), "w" (read-write),
"c" (read-write - create if necessary; the default) or
"n" (read-write - truncate to zero length). The other
arguments are rarely used and are just passed to the low-level dbopen
function. Consult the Berkeley DB documentation for their use and
interpretation.
filename[, flag[, mode[, rnflags[, cachesize[, psize[, lorder[, reclen[, bval[, bfname]]]]]]]]]) |
Open a DB record format file named filename. Files never intended
to be preserved on disk may be created by passing None
as the
filename. The optional
flag identifies the mode used to open the file. It may be
"r" (read only), "w" (read-write),
"c" (read-write - create if necessary; the default) or
"n" (read-write - truncate to zero length). The other
arguments are rarely used and are just passed to the low-level dbopen
function. Consult the Berkeley DB documentation for their use and
interpretation.
See Also: