You get a list of tuples unless you pass the fields or columns argument. In that case you get a Rows object.
On Wednesday, 17 October 2012 16:13:20 UTC-5, Simon Carr wrote: > > When I run a query using executesql, what is the object that is returned? > is it a dictionary? > > The reason I ask is that I am starting to think that the order of fields > being returned to me is not the order that I put them in the SQL statement. > As an example, I am running this code. > > def clean_qty(): > import re > rows = cmdb.executesql("select name, description_short, description, > id_product from product_lang where name like '%X%' or description_short > like '%X%' or description like '%X%'") > for row in rows: > match = re.search('(.+)X|\d*',row[0]) > prod_name = match.group(1) > match = re.search('(.+)X|\d*',row[1]) > prod_short_description = match.group(1) > cmdb(cmdb.product_lang.id_product==row[3]).update(name=prod_name, > description_short=prod_short_description) > > > When I use row[1], I am starting to think that I am not getting back > "description_short". > > Is there a way that I can refer to the fields in the result by name rather > than numeric position? > > Thanks > Simon > --