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().
The bsddb module requires a Berkeley DB library version from
3.3 thru 4.5.
A more modern DB, DBEnv and DBSequence object interface is available in the
bsddb.db module which closely matches the Berkeley DB C API
documented at the above URLs. Additional features provided by the
bsddb.db API include fine tuning, transactions, logging, and
multiprocess concurrent database access.
The following is a description of the legacy bsddb interface
compatible with the old Python bsddb module. Starting in Python 2.5 this
interface should be safe for multithreaded access. The bsddb.db
API is recommended for threading users as it provides better control.
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.
hashopen( |
filename[, flag[,
mode[, pgsize[,
ffactor[, nelem[,
cachesize[, lorder[,
hflags]]]]]]]]) |
-
Open the hash 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.
btopen( |
filename[, flag[,
mode[, btflags[, cachesize[, maxkeypage[,
minkeypage[, pgsize[, 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.
rnopen( |
filename[, flag[, mode[,
rnflags[, cachesize[, pgsize[, lorder[,
rlen[, delim[, source[, pad]]]]]]]]]]) |
-
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.
Note:
Beginning in 2.3 some Unix versions of Python may have a bsddb185
module. This is present only to allow backwards compatibility with
systems which ship with the old Berkeley DB 1.85 database library. The
bsddb185 module should never be used directly in new code.
See Also:
- Module dbhash:
- DBM-style interface to the bsddb.
Release 2.5.2, documentation updated on 21st February, 2008.
See About this document... for information on suggesting changes.
|