<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--Converted with LaTeX2HTML 98.2 beta6 (August 14th, 1998)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>7.11 bsddb --
Interface to Berkeley DB library</TITLE>
<META NAME="description" CONTENT="7.11 bsddb --
Interface to Berkeley DB library">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="lib.css">
<LINK REL="next" HREF="module-zlib.html">
<LINK REL="previous" HREF="module-whichdb.html">
<LINK REL="up" HREF="someos.html">
<LINK REL="next" HREF="bsddb-objects.html">
</HEAD>
<BODY bgcolor="#ffffff">
<div class=navigation>
<table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="bsddb-objects.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="someos.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="module-whichdb.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Python Library Reference</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="bsddb-objects.html">7.11.1 Hash, BTree and</A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="someos.html">7. Optional Operating System</A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="module-whichdb.html">7.10 whichdb  </A></span>
<br><hr></div>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION0091100000000000000000">
7.11 <tt class=module>bsddb</tt> --
         Interface to Berkeley DB library</A>
</H1>

<P>
  
<p class=availability>Availability: <span
 class=platform>Unix, Windows</span>.</p>

<P>
The <tt class=module>bsddb</tt> 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.

<P>
The <tt class=module>bsddb</tt> module is only available on Unix systems, so it is not
built by default in the standard Python distribution.  Also, there are two
incompatible versions of the underlying library.  Version 1.85 is widely
available, but has some known bugs.  Version 2 is not quite as widely used,
but does offer some improvements.  The <tt class=module>bsddb</tt> module uses the 1.85
interface.  Users wishing to use version 2 of the Berkeley DB library will
have to modify the source for the module to include db_185.h instead of
db.h.

<P>
The <tt class=module>bsddb</tt> 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.

<P>
<dl><dt><b><a name="l2h-1409"><tt class=function>hashopen</tt></a></b> (<var>filename</var><big>[</big><var>, flag</var><big>[</big><var>,
mode</var><big>[</big><var>, bsize</var><big>[</big><var>, ffactor</var><big>[</big><var>, nelem</var><big>[</big><var>,
cachesize</var><big>[</big><var>, hash</var><big>[</big><var>, lorder</var><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big>)
<dd>
Open the hash format file named <var>filename</var>.  The optional <var>flag</var>
identifies the mode used to open the file.  It may be ``r'' (read only),
``w'' (read-write), ``c'' (read-write - create if necessary) 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.
</dl>

<P>
<dl><dt><b><a name="l2h-1410"><tt class=function>btopen</tt></a></b> (<var>filename</var><big>[</big><var>, flag</var><big>[</big><var>,
mode</var><big>[</big><var>, btflags</var><big>[</big><var>, cachesize</var><big>[</big><var>, maxkeypage</var><big>[</big><var>,
minkeypage</var><big>[</big><var>, psize</var><big>[</big><var>, lorder</var><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big>)
<dd>
Open the btree format file named <var>filename</var>.  The optional <var>flag</var>
identifies the mode used to open the file.  It may be ``r'' (read only),
``w'' (read-write), ``c'' (read-write - create if necessary) 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.
</dl>

<P>
<dl><dt><b><a name="l2h-1411"><tt class=function>rnopen</tt></a></b> (<var>filename</var><big>[</big><var>, flag</var><big>[</big><var>, mode</var><big>[</big><var>,
rnflags</var><big>[</big><var>, cachesize</var><big>[</big><var>, psize</var><big>[</big><var>, lorder</var><big>[</big><var>,
reclen</var><big>[</big><var>, bval</var><big>[</big><var>, bfname</var><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big>)
<dd>
Open a DB record format file named <var>filename</var>.  The optional <var>flag</var>
identifies the mode used to open the file.  It may be ``r'' (read only),
``w'' (read-write), ``c'' (read-write - create if necessary) 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.
</dl>

<P>
<div class=seealso>
  <p class=heading><b>See Also:</b></p>

  <div class=seemodule>
<p>Module <b><tt class=module><a href="module-dbhash.html">dbhash</a></tt></b>&nbsp;&nbsp;&nbsp;(DBM-style interface to the <tt class=module>bsddb</tt>)</p>
</div>
</div>

<P>

<p><hr>
<!--Table of Child-Links-->


<UL>
<LI><A NAME="tex2html2356"
 HREF="bsddb-objects.html">7.11.1 Hash, BTree and Record Objects </A>
</UL>
<!--End of Table of Child-Links-->
<p>
<div class=navigation><hr><table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="bsddb-objects.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="someos.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="module-whichdb.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Python Library Reference</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="bsddb-objects.html">7.11.1 Hash, BTree and</A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="someos.html">7. Optional Operating System</A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="module-whichdb.html">7.10 whichdb  </A></span>
</div>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>Send comments on this document to <a href="mailto:python-docs@python.org">python-docs@python.org</a>.
</ADDRESS>
</BODY>
</HTML>
