[DB-SIG] postgres access to db structure
Frederic Vander Elst
Sat, 26 May 2001 13:39:31 +0100
I believe there is a platform-independent way of doing this :
select * from mytable where 1=3D0
from my experience, this works via mxODBC against db2, oracle, postgres, =
vfox tables types of dbs.
-freddie vander elst
add an e before the @.
Tom Renfro wrote:
> 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.atttyp=
> and b.attnum > 0 order by a.relname, b.attnum;
> It is vaguely reminiscent of the ALL_TAB_COLUMNS view in Oracle...
> firstname.lastname@example.org wrote:
> > 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
> > marshalling)
> > 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? th=
> > 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, holdin=
> > 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
> > http://mail.python.org/mailman/listinfo/db-sig
> Tom Renfro
> Software Engineer
> DB-SIG maillist - DB-SIG@python.org