[Tutor] Alternative for Shelve
Timo
timomlists at gmail.com
Tue May 12 09:59:05 CEST 2009
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')
>
>> Does someone have an alternative to Shelve?
>> It must be able to contain keys and values, and the values are a list
>> of dictionaries.
>
> A SqlLite database?
> With record where the fields correspond to your dictionary entries.
>
> ID:Date:Location
>
>> 1234567 = [{'date' : '2009-05-11', 'location' : 'Germany'}, {'date' :
>> '2009-05-04', 'location' : 'France'}]
>> 7654321 = [{'date' : '2009-03-12', 'location' : 'Belgium'}, {'date' :
>> '2009-04-23', 'location' : 'Spain'}]
>
> populating your dictionary becomes a matter of extracting the data:
>
> SELECT DATE, LOCATION FROM DATA WHERE ID = key
>
> SQLite has the advantage that the atabase is a single file and
> it is portable across platforms provided they have Sqlite installed.
> And its part of the Python standard library.
>
>
> Examples of using Sqlite in the databases topic of my tutorial.
Thank you. I will check the tutorial.
Timo
>
> HTH,
>
>
More information about the Tutor
mailing list