Rich Shepard wrote:
> On Tue, 20 Feb 2007, Paul McNett wrote:
>
>> cur.execute("select * from test")
>> rs = cur.fetchall()
>> dict_cursor = []
>> for rec in rs:
>> d = {}
>> for idx, fld in enumerate(cur.description):
>> d[fld[0]] = rec[idx]
>> dict_cursor.append(d)
>
> Paul, et al.:
>
> For several tables in our model, the above is very clear; there's a field
> name and a value for each record in the table. Now I'd like to learn how to
> handle the more complex cases such as this one:
>
> self.cur.execute("select * from voting group by cat order by pos")
>
> This table contains 31 columns (plus the built-in OID) for each
> record/row. Should I not group by and order by in the select statement, but
> do this in the banded ReportDesigner instead? If not, how should the
> dictionary of tuples be created?
You should group and order inside the SQL statement, and then when you
create your list of dicts, everything is already in the proper order and
the Group Expressions in the report writer will work correctly.
So, it sounds like you are doing it right.
--
pkm ~ http://paulmcnett.com
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users