bsddb crashes on windows

Skip Montanaro skip at pobox.com
Thu Mar 6 19:51:16 EST 2003


    Jarek> Will [the new bsddb] be compatible with current bsddb code?

There are two components to compatibility you need to consider, the API at
the Python level and the format of the bits written to database files.
There is a backwards compatibility API in the new bsddb package which is
compatible with the previous module's API.  The file format will of
necessity change, because the version of the underlying library with Python
for Windows will jump from 1.85 to 4.1.25.

There is a relatively easy way around file format incompatibility across
versions, however.  In Python 2.3 there are two new programs in the
Tools/scripts directory: db2pickle.py and pickle2db.py.  To convert an
existing database, run db2pickle.py using your currently installed version
of Python, something like:

    python2.1 db2pickle.py mydbfile.db mydbfile.pck
    rename mydbfile.db mydbfile.dbsave

Then generate a new database file using pickle2db.py with Python 2.3:

    python2.3 pickle2db.py mydbfile.db mydbfile.pck

There are options for reading/writing database files generated by
bsddb.hashopen, bsddb.btopen, bsddb.rnopen, anydbm.open and dbm.open.
(dbhash.open isn't supported separately, since it uses bsddb.hashopen under
the covers.)  The default is to read/write bsddb.hashopen files. 

You can also use these scripts to convert databases between file formats
(say, between dbm file and an anydbm file).  The only restriction is that
bsddb recno files have numeric keys and thus can't be interchanged with the
other database formats, all of whose keys are strings.  (This restriction
could be partially wormed around, but it doesn't seem worth the effort,
since it is so rarely used.)

Skip





More information about the Python-list mailing list