471,310 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 software developers and data experts.

Converting old "shelve" databases to gdbm

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.
Dec 25 '07 #1
2 1868
On Dec 24, 7:38 pm, RayOsb...@mac.com wrote:
Any tips welcome.
pickling has a text protocol that should be compatible across python
versions. Pickle each of your database entries to a different file,
then read them in the newer version of the script.

i.
Dec 25 '07 #2
On Dec 24, 10:01*pm, Istvan Albert <istvan.alb...@gmail.comwrote:
On Dec 24, 7:38 pm, RayOsb...@mac.com wrote:
Any tips welcome.

pickling has a text protocol that should be compatible across python
versions. Pickle *each of your database entries to a different file,
then read them in the newer version of the script.

i.
Thanks for the suggestion. I had forgotten that pickle by default has
an ASCII format - I've now written a couple of scripts, first in
Python 2.2 and then in the current default version to do the
translation. A bit tedious, but it works.
Dec 26 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Johan Kohler | last post: by
10 posts views Thread by Andrew Dalke | last post: by
3 posts views Thread by Michele Petrazzo | last post: by
7 posts views Thread by mwt | last post: by
reply views Thread by Kurt B. Kaiser | last post: by
2 posts views Thread by hypermonkey2 | last post: by
reply views Thread by Edwin.Madari | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.