[DB-SIG] postgres access to db structure
Fri, 25 May 2001 13:01:14 -0700
If you are looking for the column names for a table, look
in the pg_attribute table. Something like the following should
select b.attnum, a.relname,b.attname,c.typname from pg_class a,
pg_attribute b, pg_type c where a.oid=3Db.attrelid and c.oid=3Db.atttypid
and b.attnum > 0 order by a.relname, b.attnum;
It is vaguely reminiscent of the ALL_TAB_COLUMNS view in Oracle...
> Hello everybody, Im new to this list
> My configuration: linux SuSE 7.0, postgres, python 1.5.2, psycopg
> I have a little app to develop, but if this works fine, the use of db
> might spread in our apps (as an alternative to bsddb and/or
> Trying to keep all information in one place, as I have been taught, I
> try not to hardcode field names in the python code. One simple
> question: how can I query a database, to know which fields it has? the
> description attribute of a cursor seems ok to me, but its valid only
> when a query has been run, there must be a better way.
> I think I remember at least some DB (db2?) have system tables, holding
> this kind of information; is this normalized? how-to in postgres?
> I didnt find this in postgres doc.
> Sorry, its hardly a question for this list, more pure database...
> Pierre Imbaud <email@example.com>
> 12 Rue des Bosquets 91480 Quincy Sous S=E9nart France
> Tel: 01 69 00 94 57 Fax 09 47
> DB-SIG maillist - DB-SIG@python.org