Converting old "shelve" databases to gdbm

RayOsborn at mac.com RayOsborn at mac.com
Mon Dec 24 19:38:14 EST 2007


I have some old "shelve" databases created in Python 2.2  that use the
old bsddb format, whereas the version of Python 2.4 installed by my
web hosting service doesn't have bsddb available at all (or at least,
it has, but probably not linked properly to the more recent Sleepy Cat
versions of the Berkeley DB - it fails to import _bsddb).  Currently,
I have to put python2.2 in my shebangs to get the cgi scripts to run
at all.  The question is how to migrate the databases to a format
supported by my installation of Python when I don't have complete
control over how it's installed.

The databases are fairly small, so I don't need high performance.  In
some ways, the simplest thing would be to write a script within
python2.2 to read in the old databases and write them out again using,
say, gdbm.  However, I can't specify the database protocol in the old
2.2 version of shelve, and I can't use gdbm directly because it would
only accept strings as values, whereas I have Python objects.

Any tips welcome.



More information about the Python-list mailing list