[DB-SIG] How to get table names from ODBC?
M.-A. Lemburg
mal at egenix.com
Fri Aug 3 18:54:31 CEST 2007
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.
mxODBC has a .tables() catalog method which makes this kind
of introspection easy across all database backends:
.tables(qualifier=None, owner=None, table=None, type=None)
Catalog method which generates a result set having the
following schema...
See page 56 in the documentation for details on the schema:
http://www.egenix.com/products/python/mxODBC/mxODBC.pdf
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Aug 03 2007)
>>> 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,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
More information about the DB-SIG
mailing list