How to check the result from ZSQL Method
Hello Friends, I have a ZSQL Method would select one row from MySQL, then I take the result like this in a Python Scropt. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ## (Script) Pythoon ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=ar_id ##title= one_row = script.sql_Read_News(ar_id=ar_id,ar_publish='Y' ) for row in one_row: ar_id = row.ar_id . ....... ..... .. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The value of ar_id is right. But how do know there's a ar_id or some other properties. For example: How do I know, there is a "ar_head", "ar_subhead", or .......( You may tell me to check the field name of my table in my DB, but I would like to mix sereral row to a list and they come from different table..) Is there a function to check this, or I just use one_row.names() to memorize the list of the result. Is there a function to tell me exactly the type of result from the ZSQL Method ? ex: print type(row.ar_id) Many many thanks for your help. Have a nice day Terry
Thanks to the people on the list, Yap, I knew the "names()" the available column names. But actually I mix several result from different tables. Finally, I found in "Python Script". # result is the query result for i in result: if i.some_column_name_of_table1: print "Yes, we had some_column_name_of_table1" if i.some_column_name_of_table2: print "Yes, we had some_column_name_of_table2" # seems very easy, but took me hours Thanks again I hope all newbies could find the Zope way.(I'm one of them.) Terry Dieter Maurer wrote:
Terry writes:
....
ZSQL method results have a method "names" returning the available column names.
Dieter
participants (2)
-
Dieter Maurer -
Terry