<div> </div>
<div>>>> import bsddb<br>>>> a = bsddb.btopen("aaa.db", 'c')<br>>>> dir(a)<br>['__cmp__', '__contains__', '__del__', '__delitem__', '__doc__', '__getitem__', '__init__', '__iter__', '__len__', '__module__', '__repr__', '__setitem__', '_checkCursor', '_checkOpen', '_closeCursors', '_cursor_refs', '_gen_cref_cleaner', '_make_iter_cursor', 'clear', 'close', 'db', 'dbc', 'first', 'get', 'has_key', 'isOpen', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'last', 'next', 'pop', 'popitem', 'previous', 'saved_dbc_key', 'set_location', 'setdefault', 'sync', 'update', 'values']<br>
>>> a['11'] = 'xxx'<br>>>> print a<br>{'11': 'xxx'}<br>>>> a.keys()<br>['11']<br>>>> a.first()<br>('11', 'xxx')<br>>>> a['bbb'] = 'rrr'<br>
>>> a['tttt'] = '555555555'<br>>>> print a<br>{'11': 'xxx', 'tttt': '555555555', 'bbb': 'rrr'}<br>>>> a.first()<br><font color="red">('11', 'xxx')<br>
>>> a.pop('11')<br>'xxx'<br>>>> print a<br>{'tttt': '555555555', 'bbb': 'rrr'}<br>>>> print a.first()<br>Traceback (most recent call last):<br> File "<stdin>", line 1, in <module><br>
File "/usr/lib/python2.5/bsddb/__init__.py", line 277, in first<br> self._checkCursor()<br> File "/usr/lib/python2.5/bsddb/__init__.py", line 187, in _checkCursor<br> _DeadlockWrap(self.dbc.set, self.saved_dbc_key)<br>
File "/usr/lib/python2.5/bsddb/dbutils.py", line 62, in DeadlockWrap<br> return function(*_args, **_kwargs)<br>_bsddb.DBNotFoundError: (-30990, 'DB_NOTFOUND: No matching key/data pair found')<br>>>> a.first()<br>
('bbb', 'rrr')</font><br><br> </div>