Is this the way to go with SQLite

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


On Mon, Aug 24, 2015 at 2:17 AM, Dennis Lee Bieber
<wlfraed at ix.netcom.com> 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.

ChrisA


More information about the Python-list mailing list