[Zope] Get Column Names from SQL Query?

Casey Duncan cduncan@kaivo.com
Mon, 09 Apr 2001 13:38:11 -0600


Laurie Nason wrote:
> 
> OK this helps, but what I am trying to do is to generate a general report
> for any table - if I use the following dtml - how do I access the actual
> data retrieved by the query? I could call the query again and get the data
> but in terms of efficiency that is not too practical. I have looked for the
> dtml that is called when a query is tested but haven't found it yet!
> 
> <dtml-with "queries.qrytest()">
> 
> <table border=1 >
>         <tr>
>                 <dtml-in names>
>                         <th><dtml-var sequence-item></th>
>                 </dtml-in>
>         </tr>
> <dtml-comment> I WANT TO PUT THE DATA FROM THE QUERY HERE </dtml-comment>
>         <tr>
>                 <dtml-in ??????>
>                         <td><dtml-var ????></td>
>                 </dtml-in>
>         </tr>
> </table>
> </dtml-with>
> 

Here is some tested DTML code to create an HTML table from any given SQL
query:

<table border="1">
<dtml-with name="sqlMethod">
    <tr>
    <dtml-in name="names">
        <th>&dtml-sequence-item;</th>
    </dtml-in>
    </tr>
    <dtml-in name="dictionaries">
        <tr>
        <dtml-in name="values">
            <td>&dtml-sequence-item;</td>
        </dtml-in>
        </tr>
    </dtml-in>
</dtml-with>
</table>

hth,
-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>