[Zope] Get Column Names from SQL Query?

Laurie Nason laurien@tiger.bcm.tmc.edu
Mon, 9 Apr 2001 14:52:12 -0500


Excellent - this is exactly what I was looking for except that I didn't need
<dtml-with name="sqlMethod">
rather, I used
<dtml-with "sqlMethod">
Thanks again for the help.
Laurie
-----Original Message-----
From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Casey
Duncan
Sent: Monday, April 09, 2001 2:43 PM
To: Laurie Nason; Jose Soares; Thomas B. Passin; Zope Mailing List
Subject: Re: [Zope] Get Column Names from SQL Query?


Casey Duncan wrote:
>
> 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>
>

Actually, that may not put the values under the right columns, try this
instead:

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

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

_______________________________________________
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 )