How can I retrieve the ID of the last record I added?

oblomov spam at oblomov.org
Wed Jul 10 08:16:41 EDT 2002


On Wed, 10 Jul 2002 18:34:43 +0900
Ian Parker <parker at gol.com> wrote:

> In article <ef3269df.0207090751.40be10cf at posting.google.com>, Brian 
> <codeapocalypse at msn.com> writes
> >Oops.  I just realized you're accessing both MySQL as well as MSSQL.
> >My comment about @@IDENTITY applies to MSSQL.  I haven't been exposed
> >to MySQL yet.  :)
> 
> On MySQL there's a function LAST_INSERT_ID([expr]) to return the value 
> of the last auto-increment field on that connection.

The correct way would (of course?) be to retrive the OID of the last inserted record on the connection and then SELECT the data you are looking for.


karl  



More information about the Python-list mailing list