[Zope] Z SQL method results from a python script
Thomas B. Passin
tpassin@mitretek.org
Tue, 22 May 2001 11:56:52 -0400
[<daniel.a.fulton@delphiauto.com>]
>
> I want to use this method in a python script but can't for the life of me
get it
> to return the entire result set.
>
> Python script:
>
> results = context.employ_data(month=month, year=year)
>
> for result in results:
> return result.sum_hour, result.sum_total,
> result.division
>
> This returns only one record -- the first record in the result set. I
need the
> entire result set.
>
The "return" statement causes the function to end and return the result. So
you only get the first row. You should build the results into a list, then
return the list.
rows=[]
for result in results:
rows.append( (result.sum_hour, result.sum_total))
return rows
Each row is now a tuple containing the hour and sum.
Cheers,
Tom P