Is this the way to go with SQLite

Chris Angelico rosuav at
Sun Aug 23 18:22:33 CEST 2015

On Mon, Aug 24, 2015 at 2:17 AM, Dennis Lee Bieber
<wlfraed at> wrote:
>         SQLite3 supports the non-standard
>                 INSERT OR REPLACE ...
> (or one can do INSERT OR IGNORE; the OR XXX has a number of values that are
> allowed to control behavior... BUT the OR clause only applies if a UNIQUE
> constraint would be violated by the INSERT action... So if the field is not
> a unique index, no foul is detected)

Sure. But that's still the same as MySQL's (equally non-standard) "ON
DUPLICATE KEY UPDATE", and various others. It's a way of shoving down
a level the common idiom of "do this insert, only if that doesn't
work, do this update instead". But that doesn't seem to be what the
original code was doing - it was more like "do this insert, but if
it's a duplicate based on URL, check if the other fields are the same,
and if not... uhh, print something out?", which is far from common.


More information about the Python-list mailing list