Actually my patch does not allow the use of sqlite3.Row - it provides
a work around to the fact that using sqlite3.Row apparently
broke .as_list()  Basically it adds an alternate "legacyDB" argument
to db.executesql() that, when True, causes the resultset list of lists
to be converted over to a list of dictionaries keyed off of the field
names provided by the db driver (using cursor.description so
theoretically it should work with all supported DBs tho I haven't
tested).  You actually end up with the same result as you would
applying .as_list to a normal DAL query.  You wouldn't use this if
you're using the DAL, but if you're stuck with a legacy database and
need to write your own sql, it makes things easier because you can do
row['fieldname'] instead of row[0], etc. (Sorry, can't do
row.fieldname like with the DAL).  By default legacyDB = False, so
you'll only see the new behavior if you specifically request it.

Be aware that it does require looping over the entire resultset once
before the function returns, so you may wish to avoid using it with
queries that return a ton of rows. However, a quick benchmark with a
28K row table showed good performance (average time for 10 runs each):

DAL: 1.17sec
DAL + .as_list(): 1.42sec
Custom SQL and db.executesql() with legacyDB=False: 0.03sec (used
exact same sql query as DAL generated)
Custom SQL and db.executesql() with legacyDB=True: 0.13sec.

~Brian

On Dec 7, 8:00 am, Massimo Di Pierro <mdipie...@cs.depaul.edu> wrote:
> Please remind me of any pending patches. So far I have
>
> Tim (fixes python 2.5 and 2.6 incompatibilities)
> Brian (allows use of sqlite3.Row)
> New Winservice icons from Delaney
>
> Am I forgetting something?
>
> The following improvements are in trunk:
> - the trunk version now sets a default validator for DECIMAL that  
> allows negative values
> - routes_onerror pass the requested_uri upon redirect (thanks Thadeus)
> - .hgignore typos fixed
>
> Massimo

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to