[FRPythoneers] Determining berkeley version with bsddb

Jack Diederich jack at performancedrivers.com
Tue Oct 12 19:31:04 MDT 2004

On Mon, Oct 11, 2004 at 12:02:36PM -0600, Andrew Diederich wrote:
> Folks,
> I'm writing a script to convert some data from fastfile to berkely with
> python 2.2.3 on RH 9.  The bsddb module is looking like just the thing,
> and I can read and write to existing bdb files just fine.  It looks
> like the db.h on the box is 4.2.52, but rpm -q --whatprovides /usr/include/db.h
> gives me db4-devel-4.0.14-20, so I may have done something strange somewhere.
> The kicker is the application that will be using the migrated files is built
> with berkeley 3.2.9.  I'd like to be able to test to see what version
> of berkeley python is really picking up.  According to this
> (http://mail.python.org/pipermail/python-bugs-list/2002-July/012652.html)
> there is no way to do this, and I haven't seen anything like db_version
> in the pythond docs for bsddb.
> Is there a way someone has figured out how to do this?  Or am I just
> making much ado about nothing?
> Thanks for the help.

Python 2.3 does this simply,

localhost:~# python
Python 2.3.4 (#2, Sep 24 2004, 08:39:09) 
[GCC 3.3.4 (Debian 1:3.3.4-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bsddb
>>> dir(bsddb)
['UserDict', '_DBWithCursor', '__builtins__', '__doc__', '__file__', '__name__', '__path__', '__version__', '_bsddb', '_checkflag', '_db', '_iter_mixin', 'btopen', 'db', 'error', 'hashopen', 'os', 'rnopen', 'sys']
>>> bsddb.__version__

Python 2.2 requires you do it by hand, but I think it will at least tell you
the major version.

1) find where your python libraries are
>>> import sys
>>> sys.path
['', '/usr/lib/python2.2', '/usr/lib/python2.2/plat-linux2', '/usr/lib/python2.2/lib-tk', '/usr/lib/python2.2/lib-dynload', '/usr/local/lib/python2.2/site-packages', '/usr/lib/python2.2/site-packages', '/usr/lib/site-python']

2) go to the lib-dynaload directory and do
localhost:/usr/lib/python2.2/lib-dynload# strings bsddb.so | grep libdb

Humorously enough I didn't see who was sending the email until I was halfway
through replying.

'Lo Bro!


More information about the FRPythoneers mailing list