pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: The Hermit Hacker <scrappy@hub.org>
To: pgsql-sql@postgresql.org
Cc: Reshma Choodanath <creshma@lucent.com>
Subject: Listing the table fields ....
Date: Fri, 15 May 1998 00:28:02 -0300 (ADT)
Message-ID: <Pine.BSF.3.96.980515002720.438W-100000@thelab.hub.org> (raw)



===================================================================
This message has been sent to a DEAD mailing list, and subsequently
reforwarded to the proper one: pgsql-sql@postgresql.org
===================================================================


Hi,

This piece of code list the the table fields with the attribute name and the
fieldtype.
How do I get the Field size for that attribute.
f code list the the table fields with the attribute name and the fieldtype.
How do I get the Field size for that attribute?
Eg, Say one of the attributes is :-

	name varchar (50)

	I want to trap the value 50.

I tried the typlen and typprtlen, but that was not what I was looking for.

# list table fields (attribute) in given table
def ListAllFields(pgcnx, table):
        list = []
        for node in pgcnx.query("""SELECT c.relname, a.attname, t.typname 
                                                        FROM pg_class c,
pg_attribute a, pg_type t
                                                        WHERE c.relname = '%s'
AND
                                                                a.attnum > 0 AND
                                                                a.attrelid =
c.oid AND
                                                                a.atttypid =
t.oid
                                                        """ %
table).getresult():
                list.append(node[1], node[2], node[3])
        return list

Thanks,
Reshma.




Message-ID: <Pine.BSF.3.96.980515002720.438W-100000@thelab.hub.org>
Permalink:  ../Pine.BSF.3.96.980515002720.438W-100000@thelab.hub.org/
Also on:    postgresql.org/message-id/Pine.BSF.3.96.980515002720.438W-100000@thelab.hub.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: scrappy@hub.org, creshma@lucent.com
  Subject: Re: Listing the table fields ....
  In-Reply-To: <Pine.BSF.3.96.980515002720.438W-100000@thelab.hub.org>
  References: <Pine.BSF.3.96.980515002720.438W-100000@thelab.hub.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox