| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="lib.html" title='Python Library Reference' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='index' href='genindex.html' title='Index' /> |
| 10 | <link rel='last' href='about.html' title='About this document...' /> |
| 11 | <link rel='help' href='about.html' title='About this document...' /> |
| 12 | <link rel="next" href="module-dumbdbm.html" /> |
| 13 | <link rel="prev" href="module-whichdb.html" /> |
| 14 | <link rel="parent" href="someos.html" /> |
| 15 | <link rel="next" href="bsddb-objects.html" /> |
| 16 | <meta name='aesop' content='information' /> |
| 17 | <title>7.13 bsddb -- Interface to Berkeley DB library</title> |
| 18 | </head> |
| 19 | <body> |
| 20 | <DIV CLASS="navigation"> |
| 21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 23 | <tr> |
| 24 | <td class='online-navigation'><a rel="prev" title="7.12 whichdb " |
| 25 | href="module-whichdb.html"><img src='../icons/previous.png' |
| 26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 27 | <td class='online-navigation'><a rel="parent" title="7. Optional Operating System" |
| 28 | href="someos.html"><img src='../icons/up.png' |
| 29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 30 | <td class='online-navigation'><a rel="next" title="7.13.1 Hash, BTree and" |
| 31 | href="bsddb-objects.html"><img src='../icons/next.png' |
| 32 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 33 | <td align="center" width="100%">Python Library Reference</td> |
| 34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 35 | href="contents.html"><img src='../icons/contents.png' |
| 36 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 38 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 39 | <td class='online-navigation'><a rel="index" title="Index" |
| 40 | href="genindex.html"><img src='../icons/index.png' |
| 41 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 42 | </tr></table> |
| 43 | <div class='online-navigation'> |
| 44 | <b class="navlabel">Previous:</b> |
| 45 | <a class="sectref" rel="prev" href="module-whichdb.html">7.12 whichdb </A> |
| 46 | <b class="navlabel">Up:</b> |
| 47 | <a class="sectref" rel="parent" href="someos.html">7. Optional Operating System</A> |
| 48 | <b class="navlabel">Next:</b> |
| 49 | <a class="sectref" rel="next" href="bsddb-objects.html">7.13.1 Hash, BTree and</A> |
| 50 | </div> |
| 51 | <hr /></div> |
| 52 | </DIV> |
| 53 | <!--End of Navigation Panel--> |
| 54 | |
| 55 | <H1><A NAME="SECTION0091300000000000000000"> |
| 56 | 7.13 <tt class="module">bsddb</tt> -- |
| 57 | Interface to Berkeley DB library</A> |
| 58 | </H1> |
| 59 | |
| 60 | <P> |
| 61 | <A NAME="module-bsddb"></A> |
| 62 | <p class="availability">Availability: <span |
| 63 | class="platform">Unix, Windows</span>.</p> |
| 64 | |
| 65 | <P> |
| 66 | The <tt class="module">bsddb</tt> module provides an interface to the Berkeley DB |
| 67 | library. Users can create hash, btree or record based library files |
| 68 | using the appropriate open call. Bsddb objects behave generally like |
| 69 | dictionaries. Keys and values must be strings, however, so to use |
| 70 | other objects as keys or to store other kinds of objects the user must |
| 71 | serialize them somehow, typically using marshal.dumps or pickle.dumps. |
| 72 | |
| 73 | <P> |
| 74 | Starting with Python 2.3 the <tt class="module">bsddb</tt> module requires the |
| 75 | Berkeley DB library version 3.2 or later (it is known to work with 3.2 |
| 76 | through 4.3 at the time of this writing). |
| 77 | |
| 78 | <P> |
| 79 | <div class="seealso"> |
| 80 | <p class="heading">See Also:</p> |
| 81 | |
| 82 | <dl compact="compact" class="seeurl"> |
| 83 | <dt><a href="http://pybsddb.sourceforge.net/" |
| 84 | class="url">http://pybsddb.sourceforge.net/</a></dt> |
| 85 | <dd>Website with documentation |
| 86 | for the new python Berkeley DB interface that closely mirrors the |
| 87 | sleepycat object oriented interface provided in Berkeley DB 3 and 4.</dd> |
| 88 | </dl> |
| 89 | <dl compact="compact" class="seeurl"> |
| 90 | <dt><a href="http://www.sleepycat.com/" |
| 91 | class="url">http://www.sleepycat.com/</a></dt> |
| 92 | <dd>Sleepycat Software produces the |
| 93 | modern Berkeley DB library.</dd> |
| 94 | </dl> |
| 95 | </div> |
| 96 | |
| 97 | <P> |
| 98 | The following is a description of the legacy <tt class="module">bsddb</tt> interface |
| 99 | compatible with the old python bsddb module. For details about the more |
| 100 | modern Db and DbEnv object oriented interface see the above mentioned |
| 101 | pybsddb URL. |
| 102 | |
| 103 | <P> |
| 104 | The <tt class="module">bsddb</tt> module defines the following functions that create |
| 105 | objects that access the appropriate type of Berkeley DB file. The |
| 106 | first two arguments of each function are the same. For ease of |
| 107 | portability, only the first two arguments should be used in most |
| 108 | instances. |
| 109 | |
| 110 | <P> |
| 111 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 112 | <td><nobr><b><tt id='l2h-2797' xml:id='l2h-2797' class="function">hashopen</tt></b>(</nobr></td> |
| 113 | <td><var>filename</var><big>[</big><var>, flag</var><big>[</big><var>, |
| 114 | mode</var><big>[</big><var>, bsize</var><big>[</big><var>, |
| 115 | ffactor</var><big>[</big><var>, nelem</var><big>[</big><var>, |
| 116 | cachesize</var><big>[</big><var>, hash</var><big>[</big><var>, |
| 117 | lorder</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> |
| 118 | <dd> |
| 119 | Open the hash format file named <var>filename</var>. Files never intended |
| 120 | to be preserved on disk may be created by passing <code>None</code> as the |
| 121 | <var>filename</var>. The optional |
| 122 | <var>flag</var> identifies the mode used to open the file. It may be |
| 123 | "<tt class="character">r</tt>" (read only), "<tt class="character">w</tt>" (read-write) , |
| 124 | "<tt class="character">c</tt>" (read-write - create if necessary; the default) or |
| 125 | "<tt class="character">n</tt>" (read-write - truncate to zero length). The other |
| 126 | arguments are rarely used and are just passed to the low-level |
| 127 | <tt class="cfunction">dbopen()</tt> function. Consult the Berkeley DB documentation |
| 128 | for their use and interpretation. |
| 129 | </dl> |
| 130 | |
| 131 | <P> |
| 132 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 133 | <td><nobr><b><tt id='l2h-2798' xml:id='l2h-2798' class="function">btopen</tt></b>(</nobr></td> |
| 134 | <td><var>filename</var><big>[</big><var>, flag</var><big>[</big><var>, |
| 135 | mode</var><big>[</big><var>, btflags</var><big>[</big><var>, cachesize</var><big>[</big><var>, maxkeypage</var><big>[</big><var>, |
| 136 | minkeypage</var><big>[</big><var>, pgsize</var><big>[</big><var>, lorder</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> |
| 137 | <dd> |
| 138 | |
| 139 | <P> |
| 140 | Open the btree format file named <var>filename</var>. Files never intended |
| 141 | to be preserved on disk may be created by passing <code>None</code> as the |
| 142 | <var>filename</var>. The optional |
| 143 | <var>flag</var> identifies the mode used to open the file. It may be |
| 144 | "<tt class="character">r</tt>" (read only), "<tt class="character">w</tt>" (read-write), |
| 145 | "<tt class="character">c</tt>" (read-write - create if necessary; the default) or |
| 146 | "<tt class="character">n</tt>" (read-write - truncate to zero length). The other |
| 147 | arguments are rarely used and are just passed to the low-level dbopen |
| 148 | function. Consult the Berkeley DB documentation for their use and |
| 149 | interpretation. |
| 150 | </dl> |
| 151 | |
| 152 | <P> |
| 153 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 154 | <td><nobr><b><tt id='l2h-2799' xml:id='l2h-2799' class="function">rnopen</tt></b>(</nobr></td> |
| 155 | <td><var>filename</var><big>[</big><var>, flag</var><big>[</big><var>, mode</var><big>[</big><var>, |
| 156 | rnflags</var><big>[</big><var>, cachesize</var><big>[</big><var>, pgsize</var><big>[</big><var>, lorder</var><big>[</big><var>, |
| 157 | reclen</var><big>[</big><var>, bval</var><big>[</big><var>, bfname</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> |
| 158 | <dd> |
| 159 | |
| 160 | <P> |
| 161 | Open a DB record format file named <var>filename</var>. Files never intended |
| 162 | to be preserved on disk may be created by passing <code>None</code> as the |
| 163 | <var>filename</var>. The optional |
| 164 | <var>flag</var> identifies the mode used to open the file. It may be |
| 165 | "<tt class="character">r</tt>" (read only), "<tt class="character">w</tt>" (read-write), |
| 166 | "<tt class="character">c</tt>" (read-write - create if necessary; the default) or |
| 167 | "<tt class="character">n</tt>" (read-write - truncate to zero length). The other |
| 168 | arguments are rarely used and are just passed to the low-level dbopen |
| 169 | function. Consult the Berkeley DB documentation for their use and |
| 170 | interpretation. |
| 171 | </dl> |
| 172 | |
| 173 | <P> |
| 174 | <div class="note"><b class="label">Note:</b> |
| 175 | Beginning in 2.3 some Unix versions of Python may have a <tt class="module">bsddb185</tt> |
| 176 | module. This is present <em>only</em> to allow backwards compatibility with |
| 177 | systems which ship with the old Berkeley DB 1.85 database library. The |
| 178 | <tt class="module">bsddb185</tt> module should never be used directly in new code. |
| 179 | </div> |
| 180 | |
| 181 | <P> |
| 182 | <div class="seealso"> |
| 183 | <p class="heading">See Also:</p> |
| 184 | |
| 185 | <dl compact="compact" class="seemodule"> |
| 186 | <dt>Module <b><tt class="module"><a href="module-dbhash.html">dbhash</a></tt>:</b> |
| 187 | <dd>DBM-style interface to the <tt class="module">bsddb</tt>. |
| 188 | </dl> |
| 189 | </div> |
| 190 | |
| 191 | <P> |
| 192 | |
| 193 | <p><br /></p><hr class='online-navigation' /> |
| 194 | <div class='online-navigation'> |
| 195 | <!--Table of Child-Links--> |
| 196 | <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a> |
| 197 | |
| 198 | <UL CLASS="ChildLinks"> |
| 199 | <LI><A href="bsddb-objects.html">7.13.1 Hash, BTree and Record Objects</a> |
| 200 | </ul> |
| 201 | <!--End of Table of Child-Links--> |
| 202 | </div> |
| 203 | |
| 204 | <DIV CLASS="navigation"> |
| 205 | <div class='online-navigation'> |
| 206 | <p></p><hr /> |
| 207 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 208 | <tr> |
| 209 | <td class='online-navigation'><a rel="prev" title="7.12 whichdb " |
| 210 | href="module-whichdb.html"><img src='../icons/previous.png' |
| 211 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 212 | <td class='online-navigation'><a rel="parent" title="7. Optional Operating System" |
| 213 | href="someos.html"><img src='../icons/up.png' |
| 214 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 215 | <td class='online-navigation'><a rel="next" title="7.13.1 Hash, BTree and" |
| 216 | href="bsddb-objects.html"><img src='../icons/next.png' |
| 217 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 218 | <td align="center" width="100%">Python Library Reference</td> |
| 219 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 220 | href="contents.html"><img src='../icons/contents.png' |
| 221 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 222 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 223 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 224 | <td class='online-navigation'><a rel="index" title="Index" |
| 225 | href="genindex.html"><img src='../icons/index.png' |
| 226 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 227 | </tr></table> |
| 228 | <div class='online-navigation'> |
| 229 | <b class="navlabel">Previous:</b> |
| 230 | <a class="sectref" rel="prev" href="module-whichdb.html">7.12 whichdb </A> |
| 231 | <b class="navlabel">Up:</b> |
| 232 | <a class="sectref" rel="parent" href="someos.html">7. Optional Operating System</A> |
| 233 | <b class="navlabel">Next:</b> |
| 234 | <a class="sectref" rel="next" href="bsddb-objects.html">7.13.1 Hash, BTree and</A> |
| 235 | </div> |
| 236 | </div> |
| 237 | <hr /> |
| 238 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 239 | </DIV> |
| 240 | <!--End of Navigation Panel--> |
| 241 | <ADDRESS> |
| 242 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 243 | </ADDRESS> |
| 244 | </BODY> |
| 245 | </HTML> |