fastest native python database?

Ethan Furman ethan at
Fri Jun 19 17:24:05 CEST 2009

Ethan Furman wrote:
> This body part will be downloaded on demand.

Not sure what happened there... here's the text...

Howdy, Pierre!

I have also written a pure Python implementation of a database, one that 
uses dBase III or VFP 6 .dbf files.  Any chance you could throw it into 
the mix to see how quickly (or slowly!) it runs?

The code to run the same steps are (after an import dbf):

#insert test
table = dbf.Table('/tmp/tmptable', 'a N(6.0), b N(6.0), c C(100)')
# if recs is list of tuples
for rec in recs:
# elif recs is list of lists
#for a, b, c in recs:
#   current = table.append()
#   current.a = a
#   current.b = b
#   current.c = c

#select1 test
for i in range(100):
    nb = len(table)
    if nb:
       avg = sum([record.b for record in table])/nb

#select2 test
for num_string in num_strings:
records = table.find({'c':'%s'%num_string}, contained=True)
nb = len(records)
if nb:
    avg = sum([record.b for record in records])/nb

#delete1 test
for record in table:
    if 'fifty' in record.c:
# to purge the records would then require a table.pack()

#delete2 test
for rec in table:
    if 10 < rec.a < 20000:
# again, permanent deletion requires a table.pack()

#update1 test
for i in range(100):  # update description says 1000, update code is 100
    records = table.query(python='10*%d <= a < 10*%d' %(10*i,10*(i+1)))
    for rec in records:
       rec.b *= 2

#update2 test
records = table.query(python="0 <= a < 1000")
for rec in records:
    rec.c = new_c[rec.a]

Thanks, I hope!  :)


More information about the Python-list mailing list