[Zope-DB] ZSQL Result Set: How to find out column's names?

M.-A. Lemburg mal@lemburg.com
Mon, 03 Feb 2003 17:01:15 +0100


Stephan Herschel wrote:
> Hi group,
> 
> I'm testing a ZSQL Method which uses a dynamically constructed 
> sql-statement. Thus i don't know the column names of the result set.
> 
> How can I get the column names to display them in a dtml-method?
> 
> The only thing I found was a reference to the 'Searchable Object 
> Interface' in the Zope-book and a hint to a method called 
> _searchable_result_columns() which cannot be called as it starts with a '_'

The usual way to query for result columns is by adding a "and 1=0"
to the WHERE clause, e.g. SELECT * FROM MyTable WHERE 1=0 will
give you an empty result set.

You should then be able to call the .name() method on the Results
object which will give you the column names.

Not tested, but should work this way,
-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/