[egenix-users] column names ?

Steve Holden sholden at holdenweb.com
Mon Aug 4 19:31:50 CEST 2003


> -----Original Message-----
> From: egenix-users-bounces at lists.egenix.com
> [mailto:egenix-users-bounces at lists.egenix.com]On Behalf Of
> stuff at mailzilla.net
> Sent: Monday, August 04, 2003 5:00 PM
> To: egenix-users at lists.egenix.com
> Subject: [egenix-users] column names ?
> 
> 
> 
> Is there a way, via mxODBC to obtain the column names for a 
> particular 
> query.  For example,
> 
> c = db.cursor()
> 
> sql = "SELECT * FROM foo"
> c.execute(sql)
> 
> 
> I've tried c.columns()  (before and after a fetchone()) but 
> that always 
> yields -1 (at least when connected to SQL Server).  
> 
> c.colcount seems to return the correct number of columns, so 
> that could be
> useful.  Is there a way to map the column name to a column 
> number.  That
> is, if I have a colcount of 10, how can I determine the name 
> of column 4?
> 
> I suspect the answer is "no" considering that the 
> pretty_print mx.ODBC 
> method seems to be unaware of the column names (at least 
> according to the 
> mxODBC examples on the web site).
> 
> Thanks for any info,
> 
You'll see how to do that if you take a look at

	http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81189

it uses the "description" attribute of the cursor.

regards
-- 
Steve Holden                                 http://www.holdenweb.com/
Python Web Programming                http://pydish.holdenweb.com/pwp/






More information about the egenix-users mailing list