Finding primary keys in a table - Mailing list pgsql-hackers

From darcy@druid.net (D'Arcy J.M. Cain)
Subject Finding primary keys in a table
Date
Msg-id m0yyFtO-00006BC@druid.net
Whole thread Raw
Responses Re: [HACKERS] Finding primary keys in a table
List pgsql-hackers
I am trying to finish off my Python interface with some extra helper
functions and I need to find the primary key in a table if it exists.
I have two questions.

Although I can't imagine doing so, will the system allow you to create
more than one primary key on a table?  I just need to know whether I
ned to test for multiple keys.

Can someone suggest a SQL statement to pull out the primary key(s) from
a table?

Also, if multiple keys are allowed, what are people's opinions about
using them?  Basically I am creating a get function that is defined as:

def db_get(db, cl, arg, keyname = None):

where db is the database handle, cl is the class, arg is either a value
to lookup or a dictionary containing the value and keyname is the
field to lookup which defaults to the primary key.  The question is,
what do I do if keyname is omitted (defaults to primary) and there
are two primary keys.  Should I just use the first one or should I
raise an exception.  I favour the latter.

--
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 424 2871     (DoD#0082)    (eNTP)   |  what's for dinner.

pgsql-hackers by date:

Previous
From:
Date:
Subject: Large Objects buffer leak patch(es)
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] using C++ to define new functions