Newbie: Proper database for the task?

Armin Steinhoff a-steinhoff at web.de
Wed Dec 25 04:59:38 EST 2002


Paul Mackinney <paul at mackinney.net> wrote in message news:<mailman.1040763572.18941.python-list at python.org>...
> Hi, I'm writing a database

Why? I'm using gadfly ... a small SQL data base completely written in Python.

Armin 

> to track a Maildir whose message filenames
> are sequential integers padded to uniform length. The structure that
> I've adopted is to a database whose keys are integers (corresponding to
> the filenames) and whose values are dictionaries of a set of message
> properties. For example,
> 
> db[234] = {'name':'Eric Idle','email':'parrot at itsonlysleeping.com'}
> 
> All of the database modules seem to use strings for keys and values, but
> I don't want to call str() and eval() all the time. I want to use the
> fact that my records are ordered to optimize searches & relative
> lookups.
> 
> Bsddb's record number format supports integer keys, but only string
> values. Shelve's BsdDBShelf module lets me store pickleable (non-string)
> values, but doesn't work with a bsddb.rnopen() object and the other
> bsddb formats use keys that are strings.
> 
> To keep my project moving I've written a db class that uses integer
> keys, pickleable values, and has all of the dbm and bsddb methods, but
> it really feels like a hack. Surely this problem has an existing
> solution? (And yes, I've thought of using an SQL database. Users with
> large datasets will need this but I'd like to have a solution in python
> for small to moderate datasets.)
> 
> TIA, PM



More information about the Python-list mailing list