[Tutor] Python DB

Andrei project5 at redrival.net
Thu Sep 22 21:07:05 CEST 2005

> The problem (I have) with SQL-type DB is that I cannot be sure ahead of
> time of the exact data structure. The DB will be about patients, who
> have diseases, and also have treatments.....Clearly, I can't specify now
> the exact structure of the table. The advantage of SQL is that you can
> (in general) do things like constrain types for fields, and give
> enumerated options, which makes the data more consistent.

My experience:
- keeping in-memory: fast and easy as long as the amounts of data are 
*very* limited.
- kirby: I looked at it almost two years ago and it's nice, easy to use, 
but needs speedups for large amounts of data. At the time I tweaked some 
of the code and got very nice improvements (some of them are now in 
there I think).
- bsddb: very comfortable (just treat it like a dictionary), fast 
lookup, but searching in the values is slow. If you have thousands of 
records, you'll most likely need to employ some tricks to get fast 
responses when searching.
- sql (my experience is with SQLite): harder to work with (had some 
issues getting SQLObject to work with it, so I did it the very hard way 
by writing SQL statements), but insanely fast searches.

> The thing I liked about KirbyBase was that it used text files. This is a
> real advantage, as it means that I can access the data from other
> application easily, and also makes it easier to back-up (can just copy a
> few files). The same would seem to be true of the XML-based options. The

bsddb and sqlite also have single-file databases.

> The final thing is that I needs to have a simple GUI frontend. The nice
> thing about ZODB is that I could just map the eventhandlers to functions
> on objects..

sqlite has some viewers available (in my experience not quite reliable, 
but YMMV). bsddb can be inspected and manipulated easily in an 
interactive python session.

> If people have more comments in the light of the bigger spec. above, I'd
> still love to hear them...

I'd give bsddb a try if the application mainly involves looking up 
treatments/illnesses for a given patient (with the patient being the key 
in the database) or if the number of patients is quite low (hundreds). 
If however an important use is to do other types of searches too (e.g. 
find all patients with an age above X who use a drug Y) and you have a 
large database, some SQL DB would be better.



Mail address in header catches spam. Real contact info (decode with rot13):
cebwrpg5 at jnanqbb.ay. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V 
ernq gur yvfg, fb gurer'f ab arrq gb PP.

More information about the Tutor mailing list