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

Carl Karsten carl at personnelware.com
Fri Sep 21 03:48:09 CEST 2007


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?

Carl K


More information about the DB-SIG mailing list