How to get database metadata information (i.e. existing tables andcolumns in tables)

Tim Golden tim.golden at viacom-outdoor.co.uk
Tue Aug 22 08:13:22 EDT 2006


[Chris Brat]

| Is it possible to retrieve details about the database, specifically a
| list of the tables in the database; and then to retrieve the columns
| and their types for the tables?
| 
| Is this dependant on the database? 

In effect it's dependent on the database. We're assuming you're
talking about a relational databases for a start, since other
databases don't necessarily even have tables. The major databases
may support the INFORMATION_SCHEMA standard (random link:
http://www.devx.com/getHelpOn/10MinuteSolution/20561) but they
may not -- I don't think sqlite does, for example -- and their 
implementations may well vary etc.

In short, try INFORMATION_SCHEMA first. Failing that, look
at the specific db docs for the gen.

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________



More information about the Python-list mailing list