bsddb for simple database [very basic]

Al Gonzalez alberto at mindspring.com
Mon Aug 27 22:44:10 CEST 2001


Not really an answer to your question about bsddb, but rather a suggestion.

Metakit is a very simple to use database that is more powerful than the
db modules.

example (from their docs):
import metakit
db = metakit.storage("datafile.mk",1)
Create a view (this is the MetaKit term for "table"):
vw = db.getas("people[first:S,last:S,shoesize:I]"
Add two rows (this is the MetaKit term for "record"):
vw.append(first='John',last='Lennon',shoesize=44)
vw.append(first='Flash',last='Gordon',shoesize=42)
Commit the changes to file:
db.commit()
Show a list of all people:
for r in vw: print r.first, r.last, r.shoesize
Show a list of all people, sorted by last name:
for r in vw.sort(vw.last): print r.first, r.last, r.shoesize
Show a list of all people with first name 'John':
for r in vw.select(first='John'): print r.first, r.last, r.shoesize

"Artur Skura" <arturs at iidea.pl> wrote in message
news:slrn9oit5s.b5f.arturs at aph.waw.pdi.net...
> I need very simple database functionality for a weblog.
>
> (Most things generally available are very heavy, require
> Potgres/MySQL/PHP/whatever - this one will be just a little boa+a couple
> of cgi scripts, very flexible and easy to maintain).
>
> I thought about using one of the standard db modules, like bsddb. (First
> thing i have found is that documentation is quite scarce. I've seen some
> examples of using marshal with bsddb, but this seems like too much now.)
>
> I need to set up a simple database:
>
> * key
> * name
> * date
> * comment
>
> What is the simplest way to do that?
>
> ...





More information about the Python-list mailing list