Gadfly can be used in almost exactly the same way as other data sources:
>>> from gadfly import gadfly >>> connection = gadfly("test", "c:\\mydir\\gadfly\\dbtest") >>> cursor = connection.cursor() >>> cursor.execute('SELECT * FROM Frequents') >>> from pprint import pprint >>> cursor.description # only does fieldnames at present (('PERWEEK', None, None, None, None, None, None), ('BAR', None, None, None, None, None, None), ('DRINKER', None, None, None, None, None, None)) >>> print cursor.pp() # it can format its own output PERWEEK | BAR | DRINKER ============================ 1 | lolas | adam 3 | cheers | woody 5 | cheers | sam 3 | cheers | norm 2 | joes | wilt 1 | joes | norm 6 | lolas | lola 2 | lolas | norm 3 | lolas | woody 0 | frankies | pierre 1 | pans | peter >>> data = cursor.fetchall() >>>
Like most interactive SQL clients, it can format its own output with
pp() method. One immediate surprise is the
speed: Gadfly operates entirely in local memory and uses highly
refined logic to produce an extremely fast implementation. We
won’t go into how!
Gadfly offers the same ability to prepare statements as
mxODBC; if the same statement is passed in
repeated calls, the cursor parses it only once:
>>>insertstat = "insert into phonenumbers(name,phone) values (?, ?)" >>>cursor.execute(insertstat, ('nan', "0356")) >>>cursor.execute(insertstat, ('bill', "2356")) >>>cursor.execute(insertstat, ('tom', "4356")) >>>
A matrix of values can be passed to
execute() in a single try. ...