Re: [Zope] Z SQL method results from a 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.
My eurocents: return stops the current script and returns immediately. The for loop loops over all records. Att the first record it sees a return and the script stops. I am not a python expert and i didn't test it, but may be you could try something like this: To make it work you need to change your SQL method, returning only the columns you need. To be honest i couldn't make i working the way you want it. I would say this should work (but it wasn't): newresults=[] for object in context.employ_data(month=month, year=year): result=[object.sum_hour, object.sum_total, object.division] newresults.append(result) return newresults That was the best i have for you, sorry Met vriendelijke groeten, Hans de Wit Stichting Farmaceutische Kengetallen Postbus 30460 2500 GL DEN HAAG Tel. 070-3737448 Fax 070-3737445 daniel.a.fulton@delp hiauto.com To: zope@zope.org Sent by: cc: zope-admin@zope.org Fax to: Subject: [Zope] Z SQL method results from a python script 05/18/01 02:44 AM I have a Z SQL method named "employ_data" as below: SELECT SUM(employ_hour) AS sum_hour, SUM(employ_salary+employ_hour) AS sum_total, division WHERE employ_record.month=<dtml-sqlvar month type=string> AND employ_record.year=<dtml-sqlvar year type=int> GROUP BY division This method has been tested and returns multiple rows in the result set correctly with input for month, year. 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. Am I misusing this or have incorrect script? Thanks, Daniel _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (1)
-
H.de.Wit@SFK.NL