ANN : buzhug 0.4

Pierre Quentel quentel.pierre at wanadoo.fr
Tue Jun 20 15:16:07 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='Garbage',title='Bleed Like Me',issued=2005)
    my_cds.insert(artist='Rialto',issued=2002,title='Night On Earth')
    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 object 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 (see http://buzhug.sourceforge.net/performance.html
for details)

This version 0.4 improves the speed of selection on fixed-length fields
(integer, date, datetime) and introduces a syntax for request on field
values between a minimum and a maximum :

    my_cds.select(['title'],issued = [1990,1999])

Regards, 
Pierre



More information about the Python-announce-list mailing list