473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 1964
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Johan Kohler | last post by:
Hi, I have a class with attributes that are string, integer and list. eg. class person: name ="" age = 0 friends= comment=""""""
10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
3
by: Michele Petrazzo | last post by:
Hi, I'm trying a script on a debian 3.1 that has problems on shelve library. The same script work well on a fedora 2 and I don't know why it create this problem on debian: #extract from my code...
7
by: mwt | last post by:
Is there a function in python that does what "locate" does in a bash shell? I know I could do it by using os.popen('locate'), but I'm curious if there's a Python "native" way to go about it....
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 378 open ( +3) / 3298 closed (+34) / 3676 total (+37) Bugs : 886 open (-24) / 5926 closed (+75) / 6812 total (+51) RFE : 224 open...
1
by: Joe Peterson | last post by:
I've been doing a lot of searching on the topic of one of Python's more disturbing issues (at least to me): the fact that if a __del__ finalizer is defined and a cyclic (circular) reference is...
2
by: hypermonkey2 | last post by:
Hi there! I am using the "shelve" module in a script to save information in between runtime sessions of the program. (its a sort of data collector, so its important to hold on to anything computed...
0
by: Edwin.Madari | last post by:
since choice of dbm used by shelve http://docs.python.org/lib/node327.html depends on os, and whats available on it, shevle files saved on one os, most likely do not work on another os, sometimes on...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.