ANN: buzhug, a new pure-Python database engine

Pierre Quentel quentel.pierre at wanadoo.fr
Sat May 27 20:30:33 CEST 2006


buzhug is a new, fast, pure-Python database engine, using a pythonic
syntax (no SQL). It is published at http://buzhug.sourceforge.net under
the BSD licence

Here is an overview of the interface :

    from buzhug import Base

    my_cds = Base('my_cds')
    my_cds.create(('artist',str),('title',str),('issued',int))

    my_cds.insert(artist='Kaiser
Chiefs',title='Employment',issued=2005)
    my_cds.insert(artist='Rialto',title='Night On Earth',issued=2002)
    my_cds.insert('Oasis','Definitely Maybe',1994)

    cd = my_cds.select(artist="Oasis")[0]
    print cd.title
    > "Definitely Maybe"

    new_cds = [ cd for cd in my_cds if cd.issued > 2000 ]

Pretty straightforward, isn't it ? As you can see on the last line, the
database is an iterator, yielding objects which have attributes of the
same name as the fields in the base

    songs = Base('songs')
    songs.create(('title',str),('cd',my_cds))

    cd = my_cds.select(title="Definitely Maybe")[0]
    song_id = songs.insert('Supersonic',cd)

    song = songs[song_id]   # lookup by record id
    print song.cd.artist
    > "Oasis"

A field can be a reference to another database. When you have finished
entering all the songs you can get the track listing by

    [ song.title for song in songs if song.cd.title == "Definitely
Maybe" ]

A complete documentation, with a tutorial, is available on the web site

The implementation has been designed to make all operations, especially
selection, as fast as possible, while processing the data on disk (it
is not an in-memory database). On a limited set of tests I found that
it is much faster than gadfly and KirbyBase, and only less than 3 times
slower than SQLite

This is still a beta version, so I need feedback on the syntax,
performance, bug reports etc. Please send any comment or question to
the Google group : http://groups.google.com/group/buzhug?lnk=li

Regards,
Pierre



More information about the Python-announce-list mailing list