[DB-SIG] How to get table names from ODBC?

M.-A. Lemburg mal at egenix.com
Fri Sep 21 11:49:21 CEST 2007

Carl Karsten wrote:
> M.-A. Lemburg wrote:
>> On 2007-08-03 17:23, Lukasz Szybalski wrote:
>>> Hello,
>>> I am using python win32 extentions.
>>> I get connected via odbc to a database files that are sitting in the folder.
>>> import dbi,odbc
>>> db=odbc.odbc('dbfiles')
>>> cursor=db.cursor()
>>> cursor.execute('select * from tableabcd')
>>> print  cursor.description
>>> This way I am able to find column names.
>>> How do i find a available table names?  I have 20 tables available to
>>> me. How do I list their names??
>> With the old odbc module this is not possible without knowing
>> the database internals.
> What is described here?
> http://pyodbc.sourceforge.net/docs.html#cursor_tables
> Executes SQLTables and creates a results set of tables defined in the data 
> source. Returns the Cursor.
>    for row in cursor.tables():
>        print row.table_name
> Is there a comparison between pyodbc, mxodbc, ceodbc - did I mis any?

Yes, you missed the old win32 odbc module which is what I was
referring to.

mxODBC provides the whole set of ODBC catalog functions in
form of cursor methods and this makes it possible to query
meta information in a database independent way.

For more information, please see the mxODBC documentation.
Look for the section 6.3.1 Catalog Methods:


Marc-Andre Lemburg

Professional Python Software directly from the Source
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::

More information about the DB-SIG mailing list