PostgreSQL, psycopg2 and OID-less tables

Tim N. van der Leeuw tnleeuw at gmail.com
Fri Sep 15 11:58:49 EDT 2006


Dale Strickland-Clark wrote:
> Now that OIDs have been deprecated in PostgreSQL, how do you find the key of
> a newly inserted record?
>
> I've tried three Python client libraries, including psycopg2, and where they
> support cursor attribute 'lastrowid' (Python DB API 2.0), it is always
> zero.
>
> Anyone figured this out?
>

Hi,

It's of course strictly a PostgreSQL question, but have you tried

select lastval();

?

According to my reading of the postgress manuals, that should do the
trick.

Cheers,

--Tim


> Thanks.
> -- 
> Dale Strickland-Clark
> Riverhall Systems - www.riverhall.co.uk




More information about the Python-list mailing list