Many thanks for the speedy reply. I don't know how your're going to do it, but in case it's any use here's the sql that I used with pyPgSQL:

    s1 = 'SELECT b.attname FROM pg_constraint a, pg_attribute b '
    s2 = 'WHERE a.conrelid = (\'%s\'::regclass) ' % tablename
    s3 = 'AND a.conrelid = b.attrelid '
    s4 = 'AND b.attnum = ANY(a.conkey) AND a.contype = \'p\''
    return s1 + s2 + s3 + s4

I can't remember why I split it up like that.

Paul Hide
On 24/05/06, Christoph Zwerschke <[EMAIL PROTECTED]> wrote:
Paul Hide wrote:
> I am experimenting with pygresql as an alternative to pyPgSQL. So far,
> it has been a good experience. However, I was surprised to see that
> pg.pkey only returns one attribute/column name of a table that has a
> composite primary key.

I think PyGreSQL never supported composite primary keys in pkey() and
get(). A backward compatible fix would be to let pkey() return the name
of the primary key if it is a single column, or a tuple of column names
if it is a composite key. get() should cope with composite keys as well,
and also allow tuples for the keyname attribute.

If nobody disagrees, I'll try to add this over the weekend. This could
then go into PyGreSQL 3.9.

-- Christoph
_______________________________________________
PyGreSQL mailing list
[email protected]
http://mailman.vex.net/mailman/listinfo/pygresql

_______________________________________________
PyGreSQL mailing list
[email protected]
http://mailman.vex.net/mailman/listinfo/pygresql

Reply via email to