i have this sqlite table:
CREATE TABLE frames (videomd5 TEXT, framemd5 TEXT, type TEXT, PRIMARY KEY (videomd5, framemd5))
As you can see, the table has a combined PRIMARY KEY because it is allowed that one of the fields has the same values but never both at once.
Currently I’m performing a check like this
SELECT framemd5 FROM frames WHERE framemd5='$digest' AND videomd5='$videomd5'
before adding something to the table to avoid a PRIMARY KEY CONTRAINTs but i feel there is a better way to handle it. Should i fire the INSERT without checking first and handel the CONSTRAINT afterwards? If so, how is this best done in perl?
Thank you
Yes you can use the “OR IGNORE” in your insert, eg:
Refer to the official doc for the details:
http://www.sqlite.org/syntaxdiagrams.html#insert-stmt