From: | The Hermit Hacker <scrappy(at)hub(dot)org> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Cc: | Reshma Choodanath <creshma(at)lucent(dot)com> |
Subject: | Listing the table fields .... |
Date: | 1998-05-15 03:28:02 |
Message-ID: | Pine.BSF.3.96.980515002720.438W-100000@thelab.hub.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
===================================================================
This message has been sent to a DEAD mailing list, and subsequently
reforwarded to the proper one: pgsql-sql(at)postgresql(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Igor Sysoev | 1998-05-15 06:24:38 | Re: [SQL] Perl and SQL |
Previous Message | Jose' Soares Da Silva | 1998-05-14 10:57:09 | Re: Referential Integrity |