Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!rt.uk.eu.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:bug': 0.05; '(so': 0.07; '21,': 0.07; 'filename': 0.07; 'nicely': 0.07; 'subject: + ': 0.07; 'subject:sqlite3': 0.07; 'cursor': 0.09; 'sqlite': 0.09; 'subject:Python3': 0.09; 'dec': 0.15; '(something': 0.16; 'code?': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'here).': 0.16; 'merely': 0.16; 'part-way': 0.16; 'scratch': 0.16; 'sqlite3': 0.16; 'wrote:': 0.17; "shouldn't": 0.17; 'yield': 0.17; 'fairly': 0.21; 'affected': 0.22; 'example': 0.23; 'this:': 0.23; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'separate': 0.27; 'i.e.': 0.27; 'then.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'source': 0.29; "i'm": 0.29; 'connection': 0.30; 'connections': 0.30; 'fri,': 0.30; 'code': 0.31; 'point': 0.31; 'file': 0.32; 'that!': 0.33; 'to:addr:python- list': 0.33; 'received:google.com': 0.34; 'wrong': 0.34; 'open': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'but': 0.36; "didn't": 0.36; "i'll": 0.36; 'should': 0.36; 'option': 0.37; 'two': 0.37; 'received:209': 0.37; 'well.': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'performance': 0.39; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'improvements': 0.65; 'connection,': 0.71; 'obvious': 0.71; 'connection.': 0.75; 'bow': 0.84; 'break.': 0.84; 'subject:Where': 0.84; 'for).': 0.91; 'anymore,': 0.95 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:to :content-type; bh=QYfCAV5OTCkJIOsTcNA/Kj9pV2qKrKCPW7LQbB/LN0A=; b=CqoDeFEtj0dEcby5qFJ55vDmuYBRJNC1FlFv6GwGx2GkHscfF5ggX44eVlCHsNoXqB E0d+PH+A2yB1MSBwt9TJIzKxAd1yN9vh1RxRDni2qOTXReXAceUtbp7OttGXFyWqm9bP ml8MQu2rIgYOupMO3SjeGqQkizQurYzmOdkW195q0sinP7Z1dm0clTlweQRAvkjHUC65 FKcd+sDzFwjoVrs+847eL1Ldn3hy2gEje+OHAozT21VXF1Tf8MInHDVmiWeIZqLmndIP zb6TOJ1Ac3xTlQyWtAwDZ4Euc4WyhGjiyCilUr2ogqDLywql3P4H0/C6EVYJ9O5Fq9xV /DvQ== MIME-Version: 1.0 In-Reply-To: References: Date: Fri, 21 Dec 2012 02:55:51 +1100 Subject: Re: Python3 + sqlite3: Where's the bug? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 1356018959 news.xs4all.nl 6958 [2001:888:2000:d::a6]:37698 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35203 On Fri, Dec 21, 2012 at 2:20 AM, Johannes Bauer wrote: > Hmm, but this: > > result = cursor.fetchone() > yield result > > Works nicely -- only the fetchmany() makes the example break. Okay, now it's sounding specific to sqlite. I'll bow out. :) > >> Would it spoil your performance improvements to do all the fetchmany >> calls before yielding anything? > > Well this would effectively then be a fetchall() call -- this is > problematic since the source data is LARGE (spekaing of gigabytes of > data here). That would be a "yes", then. Scratch that! >> Alternatively, can you separate the >> two by opening a separate database connection for the foo-reading (so >> it isn't affected by the commit)? > > At that point in the code I don't actually have a filename anymore, > merely the connection. But shouldn't the cursor actually be the > "correct" solution? I.e. in theory, should the example work at all or am > I thinking wrong? You say "db.commit()", not "cur2.commit()", so I don't see that a cursor would un-break what part-way commits is breaking. > Because if I'm approaching this from the wrong angle, I'll have no > choice but to change all that code to open separate connections to the > same file (something that currently are no provisions for). Is that an sqlite limitation, or just one of your code? I poked around at the sqlite3 docs, but didn't find any obvious "clone" option on the connection, nor a way to retrieve the file name. That would have been fairly convenient. Oh well. ChrisA