[Zope] Retrieving Rows, Columns, and ??Column Headings?? from RDB?

Oliver Bleutgen Oliver Bleutgen <myzope@gmx.net>
Thu, 13 Sep 2001 20:12:24 +0200


> Using an external database such as MySQL, does Zope(2-3-2)
> (or Python-in-Zope) provide any mechanism to retrieve the
> names of the columns queried, rather than simply the DATA
> within those columns?

> Please allow me to obfuscate this question with an example
> of what I need.. :-)

several ways to achieve what you want:

<dtml-with "user_query(fname='Bob')">
<dtml-in dictionaries>
<dtml-var sequence-item>
</dtml-in>
</dtml-with>

returns for each sequence item a dictionary of name:value pairs.
Equivalent: <dtml-in "user_query(fname='Bob').dictionaries()">

"user_query(fname='Bob').names()" gives a list of the column names
"user_query(fname='Bob').tuples()" returns a list(tuple?) of the
result rows in a tuple (better try it, words lost me).

So you could also combine names() and tuples()

cheers,
oliver