python - Return existing primary key ID upon constraint failure in sqlite3 -


i have unique constraint on 2 columns of table in sqlite.

if insert record duplicate on these 2 columns table, exception (sqlite3.integrityerror).

is possible retrieve primary key id of record upon such violation, without doing additional select?

if primary key part of unique constraint led violation, have value.

otherwise, 2 columns in unique constraint alternate key table, i.e., can uniquely identify conflicting row.

if need actual primary key, need additional select. (the primary key of existing row not part of exception because never looked @ during insert attempt.)


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -