mxODBC: Getting source table for columns in the cursor.description

M.-A. Lemburg mal at lemburg.com
Tue May 6 09:00:29 EDT 2003


Sean wrote:
> Quick mxODBC question.  I have a db with two tables, 'accounts' and
> 'contacts', where both tables have a column named 'phonenumber'.  I'm
> pushing an SQL select statement using Egenix's mxODBC along the lines
> of "select * from accounts a1 INNER JOIN contacts c1 on a1.<some
> column> = c1.<some column>".
> 
> Everything works great.  The only problem is when I get the
> description from the cursor I have a list of column names without
> knowing what table they came from.  Using the above example, I would
> have two "phonenumber" columns listed in the description.  Is there a
> way to determine which listing came from which table?  I would like to
> avoid having to rewrite my SQL statement to specifically list each and
> every column selected with "select x as table.x", but I need a way to
> know what columns came from which table.  Is there functionality built
> into mxODBC to do this that I'm missing?  I've been going through the
> API here:
> 
> http://www.egenix.com/files/python/mxODBC.html
> 
> but without any luck.

You could try: select accounts.*, contacts.* from ...
Not sure whether that works with the database you're
using, though.

There's no generic API in ODBC to query this kind of information.

HTH,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Software directly from the Source  (#1, May 06 2003)
 >>> Python/Zope Products & Consulting ...         http://www.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
EuroPython 2003, Charleroi, Belgium:                        49 days left






More information about the Python-list mailing list