Massimo, executesql() isn't working correctly with the new DAL in
trunk. The fix looks to be easy, simply replace self._cursor with
self._adaptor.cursor this fixes things for SQLite and I would assume
the other DBs as well - I can try testing MS SQL tomorrow.

Fixed code is below, should be right around line 3345...

def executesql(self, query, placeholders=None, as_dict=False):
"""
<snip>docstring removed for brevity</snip>
"""
if placeholders:
self._adapter.execute(query, placeholders)
else:
self._adapter.execute(query)
if as_dict:

if not hasattr(self._adapter.cursor,'description'):
raise RuntimeError, "database does not support
executesql(...,as_dict=True)"
# Non-DAL legacy db query, converts cursor results to dict.
# sequence of 7-item sequences. each sequence tells about a column.
# first item is always the field name according to Python Database API
specs
columns = self._adapter.cursor.description
# reduce the column info down to just the field names
fields = [f[0] for f in columns]
# will hold our finished resultset in a list
data = self._adapter.cursor.fetchall()
# convert the list for each row into a dictionary so it's
# easier to work with. row['field_name'] rather than row[0]
return [dict(zip(fields,row)) for row in data]
# see if any results returned from database
try:
return self._adapter.cursor.fetchall()
except:
return None

~Brian M

Reply via email to