Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'interfaces': 0.04; 'parameters': 0.04; 'value,': 0.04; 'argument': 0.05; 'method.': 0.07; 'referring': 0.07; "subject:' ": 0.07; 'back-end': 0.09; 'lawrence': 0.09; 'parameter': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'referenced': 0.09; 'language.': 0.14; '"..."': 0.16; '(other': 0.16; '-tkc': 0.16; 'essential,': 0.16; 'placeholder': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sqlite': 0.16; 'subject:dates': 0.16; 'subject:sqlite3': 0.16; 'tuple': 0.16; 'language': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'code,': 0.22; 'header:User-Agent:1': 0.23; 'processor': 0.24; 'query': 0.26; 'second': 0.26; 'values': 0.27; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; 'chase': 0.31; 'parameters.': 0.31; 'run': 0.32; 'url:python': 0.33; 'subject: (': 0.35; 'something': 0.35; 'but': 0.35; 'url:org': 0.36; 'should': 0.36; 'ends': 0.38; 'mine': 0.38; 'saves': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'fact': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'url:3': 0.61; 'back': 0.62; 'times': 0.62; 'such': 0.63; 'our': 0.64; 'provide': 0.64; 'different': 0.65; 'here': 0.66; 'wish': 0.70; 'miss': 0.74; 'misses': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: 'Lite' Databases (Re: sqlite3 and dates) Date: Thu, 19 Feb 2015 15:04:47 +0000 References: <4154cc37-0bb0-4bf2-a52c-b728c737357c@googlegroups.com> <54E517B4.4000409@stoneleaf.us> <20150219081758.3dbe83ca@bigbox.christie.dr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: host-92-24-222-48.ppp.as43234.net User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 In-Reply-To: <20150219081758.3dbe83ca@bigbox.christie.dr> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424358311 news.xs4all.nl 2839 [2001:888:2000:d::a6]:35270 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85905 On 19/02/2015 14:17, Tim Chase wrote: > On 2015-02-19 05:32, Mark Lawrence wrote: >> On 19/02/2015 00:08, Mario Figueiredo wrote: >>> Parameterized queries is just a pet peeve of mine that I wish to >>> include here. SQLite misses it and I miss the fact SQLite misses >>> it. The less SQL one needs to write in their code, the happier >>> one should be. >> >> Instead, use the DB-API’s parameter substitution. Put ? as a >> placeholder wherever you want to use a value, and then provide a >> tuple of values as the second argument to the cursor’s execute() >> method. (Other database modules may use a different placeholder, >> such as %s or :1.) For example:..." > > I think Mario was referring to what other back ends call prepared > statements. So you do something like > > > sql = "..." # parameters are referenced here > conn = sqlite3.connect(...) > stmt = conn.prepare(sql) > for parameters in list_of_parameters: > stmt.execute(*parameters) > > This saves the SQL processor from recompiling the SQL into internal > byte-code every time. It's handy if you know a given query will run > multiple times with the same "shape" parameters. It's not essential, > and some optimize away the need, but many back-end interfaces support > it. > > -tkc > Is this https://docs.python.org/3/library/sqlite3.html#sqlite3.Cursor.executemany an equivalent? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence