[DB-SIG] Dumping Table Schema
Tue, 05 Dec 2000 17:53:31 +0100
Paul DuBois wrote:
> At 7:10 PM -0500 12/1/00, Jonan Santiago wrote:
> >Thanks both for your tips. Just what I needed. Now I dont know
> >why "select * from table where 1=0" works but it works!
> Per the original question, my understanding (from some discussion a
> while back on the DBI mailing list) is that this actually isn't
> completely portable. Although it works for many database engines, it
> doesn't work for all. Sorry, don't know any examples where it doesn't
> work. I do know it does work for MySQL.
FYI, It works for mxODBC too (and all supported database backends).
The only thing to watch out for whether or not the column
names include the table name or not and whether they are
case sensitive or not.
Note that in mxODBC you can also use the catalog methods to
get some more information about the database schema from the
database. These map to ODBC calls which translate the request
into the database specific versions.
> >Eugene V . Dvurechenski (email@example.com) wrote:
> >> i believe, the only _portable_ way is to
> >> 1) cursor.execute( "select * from table where 1=0" )
> >> 2) use cursor.description
> >> anything else is tightly bound to the specific DBMS (all those
> >> SYS.ALL_* views in Oracle, for instance)
> >> -jno
> >DB-SIG maillist - DB-SIG@python.org
> DB-SIG maillist - DB-SIG@python.org
Python Pages: http://www.lemburg.com/python/