Path: csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!bcyclone04.am1.xlned.com!bcyclone04.am1.xlned.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.036 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'clause': 0.07; 'cc:addr :python-list': 0.09; 'applies': 0.15; '24,': 0.16; 'foul': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:mail-ig0-x22a.google.com': 0.16; 'sqlite3': 0.16; 'sure.': 0.16; 'violated': 0.16; 'wrote:': 0.16; 'duplicate': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'aug': 0.20; 'work,': 0.21; 'am,': 0.23; '(or': 0.23; 'insert': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; "doesn't": 0.26; 'message-id:@mail.gmail.com': 0.27; 'values': 0.28; '"do': 0.29; 'index,': 0.29; 'print': 0.30; 'code': 0.30; 'common': 0.33; 'received:google.com': 0.35; 'replace': 0.35; 'something': 0.35; 'level': 0.35; 'supports': 0.35; 'but': 0.36; 'others.': 0.36; 'subject:: ': 0.37; 'seem': 0.37; 'doing': 0.38; 'subject:the': 0.39; 'subject:with': 0.40; 'still': 0.40; 'field': 0.60; 'skip:n 10': 0.62; 'more': 0.63; 'chrisa': 0.84; 'idiom': 0.84; 'insert,': 0.84; 'not...': 0.84; 'subject:this': 0.85; 'to:none': 0.91; 'dennis': 0.91; 'same,': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=qv6T1EwcdMwKKnHfcsjyajToexMl2snXdzhKsFMYcbA=; b=GNoKryIlBac6H4/AthlcR5GP51IMnYP/vpupRdLMmHk4nnHLKjuDcKy4HtxKGvs8MC 0AHbCzWrlj+0pHsMznManRDegK8CAiPo9872Veo2WrFQtG57FzDpTcj2vsctyQ2DvvFs JqdOVPxOvtdT0ZCcoQIn2hNwzxe1qxBAeteKb1M5yedxLvRdR1FKmMPlXPAcTAJpLiHx UJwBFFVf6CaW5FpYJstXm65Ba+C16tFcVz6FiO0npHycFzPGqRfjF38NA0uwKjX+1Qei +c9+5yL9IZTaQ6EiwIUkR6gVff3Dr9lRruxmLGTBYLJZ1DhlLeoFrtHbQQENcrh+8zOM SlAg== MIME-Version: 1.0 X-Received: by 10.50.114.100 with SMTP id jf4mr12629732igb.94.1440346953443; Sun, 23 Aug 2015 09:22:33 -0700 (PDT) In-Reply-To: References: <871teum9c2.fsf@Equus.decebal.nl> Date: Mon, 24 Aug 2015 02:22:33 +1000 Subject: Re: Is this the way to go with SQLite From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1440346961 news.xs4all.nl 23772 [2001:888:2000:d::a6]:34453 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 4303 X-Received-Body-CRC: 4185125553 Xref: csiph.com comp.lang.python:95596 On Mon, Aug 24, 2015 at 2:17 AM, Dennis Lee Bieber 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