[Zope-DB] python scripts . again

D. Rick Anderson ruger@acsnv.com
06 Mar 2003 10:48:40 -0800

Still being Mr. Newbie here. While iterating through the results of an
SQL query. How do I get the column names? I'm running a query that can
return different columns depending on how it's run, and I need the
script to pull the column names:

results = context.TestSQL(cltid=102)
if results:
    print results
    for row in results:
        for column in row:
            print column

return printed

So what exactly is results? Is it a list of dictionaries? If that's the
case then this is just a python question. How do I get a list of the
keys in each dictionary?