From: <gdr...@ya...> - 2003-08-13 15:02:54
|
--- robert ackerman <rd...@pa...> escribió: > is it possible (easy?) to get field names and types > from postgresql > using pyPgSQL? > i did it before using libpq calls, but can it be > done with the high > level interface? > guess i can use high level for everything except > getting > fieldnames/types. > > > > - Hi Robert: I used an sql way to solve that problem. It worked fine --------------------------- #captures the meta-information from a table query="select a.attname, t.typname, a.attlen, a.atttypmod" query=query+" from pg_type t, pg_attribute a, pg_class c" query=query+" where c.relname = '" + tablename + "'" query=query+" and c.relfilenode = a.attrelid and a.attnum > 0" query=query+" and a.atttypid = t.oid;" try: curlocal.execute(query) except PgSQL.Error, msg: return 'query fail' --------------------------- Postgres mantains all the meta-information about tables in tables as well. I just looked inside them and made some joins to handle all the information i'd needed.(it wasnt easy) I hope it works for you. _________________________________________________________ Do You Yahoo!? Información de Estados Unidos y América Latina, en Yahoo! Noticias. Visítanos en http://noticias.espanol.yahoo.com |