Re: fielldnames

Gaston Droguett <gdroguett-/[email protected]> Wed, 13 Aug 2003 09:45:22 -0500 (CDT)
Newsgroups gmane.comp.python.db.pypgsql.user
Message-ID <[email protected]>
 --- robert ackerman <rdacker-yBeKhBN/[email protected]> 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


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01