I am reposting since I realized that I had some extraneous code on the end of my original dtml. ----- Original Message ----- From: Jim Sanford <[EMAIL PROTECTED]> To: Curtis Maloney <[EMAIL PROTECTED]>; Zope List <[EMAIL PROTECTED]> Sent: Wednesday, May 31, 2000 10:14 AM Subject: Re: [Zope] how do I get field names from a query You need an external method to get the dictionary object that has the field names mapped to column number Here is the external method: --------------------------------- def doPySQL(self, zQry) : tvar1 = 'res=self.'+zQry exec tvar1 return res._schema.items() ------------------------------------------ Here is a dtml document that uses the external method: (getRes is what I call the external method in Zope) This was for proof of idea - it is not pretty ------------------------------------------------------------------- <html><head><title>Test</title></head><body> <dtml-with "_.namespace(t1=getRes('Your_Query_Here()'))"> <dtml-var "_.len(t1)"> Columns<br> <dtml-var "_.str(t1)" html_quote><br><br> <dtml-in t1> <dtml-var "_.str(_['sequence-key'])"> = <dtml-var "_.str(_['sequence-item'])"><br> </dtml-in> <br><br> </dtml-with> </body></html> --------------------------------------------------------------------------------- ----- Original Message ----- From: Curtis Maloney <[EMAIL PROTECTED]> To: Adam Molyneaux <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, May 30, 2000 11:31 PM Subject: Re: [Zope] how do I get field names from a query On Wed, 31 May 2000, Adam Molyneaux wrote: > how do I get the names of the fields returned from a SQL query ? > ( I would like to generate stuff using the names automatically) > I know they must be available because I can use them directly ! > > I've tried lots of alternatives of the form > > <dtml-in "sqlListTable(table_name='personnel')"> > <dtml-in sequence-item> > <P><dtml-var sequence_item> > </dtml-in > Ok... someone may have already answered this, but here's my guess. (Yes, this is untried, sorry :) <dtml-in "sqlQueryBlah()"> <dtml-in sequence-item> <dtml-var sequence-key> = <dtml-var sequence-item> </dtml-in> </dtml-in> > > > which give me the values but not the names, and looked through lots of the > old msgs. I'm certain this was tackled some time in the past, but yeh, searching the list logs can sometime be suprisingly fruitless. > > Thanks in advance if anyone can help > glad i could help. (o8 > adam > [EMAIL PROTECTED] > -- Have a better one, Curtis. <dtml-var standard_work_disclaimer> _______________________________________________ Zope maillist - [EMAIL PROTECTED] 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 ) _______________________________________________ Zope maillist - [EMAIL PROTECTED] 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 )