[Tutor] Alternative for Shelve
kent37 at tds.net
Tue May 12 12:58:56 CEST 2009
On Tue, May 12, 2009 at 3:59 AM, Timo <timomlists at gmail.com> wrote:
> Alan Gauld schreef:
>> "Timo" <timomlists at gmail.com> wrote
>>> I have an issue with the Shelve module. It works great for my needs, the
>>> only problem is that a file made with Shelve isn't interchangable between
>>> different computers.
>> I thought it would be.
>> What kind of computers are you having issues with?
>> And what kind of issues?
> Currently only tested between Ubuntu and Windows on the same computer.
> This is the end of the traceback:
> bsddb.db.DBInvalidArgError: (22, 'Invalid argument -- </path/to/shelvefile>:
> unsupported hash version: 9')
shelve relies on the anydbm module for storage. anydbm may use any one
of several actual database implementations (dbhash, gdbm, dbm or
dumbdbm) depending on what is available. I guess you have different
modules available on the two machines. You can find out which module
is being used like this:
In : import anydbm
In : anydbm._defaultmod
Out: <module 'dbhash' from
You could force the use of a common db module by opening the file
explicitly. For example, to use dumbdbm, which is slow, simple and
guaranteed to be available, something like this (untested) should
from shelve import Shelf
shelf = Shelf(dumbdbm.open('myfile', 'c'))
More information about the Tutor