samedi 25 avril 2015

Return existing primary key ID upon constraint failure in sqlite3

I have UNIQUE constraint on two columns of a table in SQLite.

If I insert a record with a duplicate on these two columns into the table, I will get an exception (sqlite3.IntegrityError).

Is it possible to retrieve the primary key ID of this record upon such a violation, without doing an additional SELECT?

Aucun commentaire:

Enregistrer un commentaire