Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.albasani.net!newsreader4.netcologne.de!news.netcologne.de!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!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.059 X-Spam-Evidence: '*H*': 0.88; '*S*': 0.00; 'correct.': 0.07; 'correspond': 0.09; 'cc:addr:python-list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'statements,': 0.16; 'wrote:': 0.18; 'library': 0.18; 'commit': 0.19; 'work,': 0.20; 'seems': 0.21; 'cc:addr:python.org': 0.22; 'logical': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'database,': 0.30; 'message-id:@mail.gmail.com': 0.30; 'that.': 0.31; 'usually': 0.31; 'fri,': 0.33; 'connection': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'should': 0.36; 'nov': 0.38; 'issue': 0.38; 'pm,': 0.38; 'even': 0.60; 'units': 0.60; 'different': 0.65; 'between': 0.67; 'frank': 0.68; '4:44': 0.91; 'to:none': 0.92; 'state.': 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:cc :content-type; bh=2oyNzdku+0XnSJgzUS9hulvU9fTwYsqs+xrz8Sp2WwI=; b=y2nbfoKpkpKdCubNUCRtwVPDjxfF7ZPx5AMhmNmytdDExSNddOTdmK7heL1rgpYJZe C3i9B97/zwdW4HG7Tcf61efYeWD/y5So6+CugPFd66UjBX1JxMklg++pIZY5Z8fgIp0a 8SH9QYUccIw81yHhthUHz6Wer7RYggzNSCvIuC4NIwoIV/MxtknFtPiO7OMsTLLcHgu/ wTt4XdCTup1NNx6FtzSdXS5bkVfEAnzMKcqFAPpS2HJnISqtPYRKdGf1IGjiO86RqHyJ bZtVhnxi1ObzQWvz6R8yPbj0/dvZZF1ZN813yt7A2yWmNnUbZj9jzli1TDj+nGhS8U9I 4m4w== MIME-Version: 1.0 X-Received: by 10.42.130.194 with SMTP id w2mr17654569ics.12.1417154097924; Thu, 27 Nov 2014 21:54:57 -0800 (PST) In-Reply-To: References: <4loe7at2ls7tfq0oe041ru9svvsm8aksik@4ax.com> Date: Fri, 28 Nov 2014 16:54:57 +1100 Subject: Re: Db transactions and locking 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.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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1417154102 news.xs4all.nl 2900 [2001:888:2000:d::a6]:59399 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 3696 X-Received-Body-CRC: 2180759790 Xref: csiph.com comp.lang.python:81668 On Fri, Nov 28, 2014 at 4:44 PM, Frank Millman wrote: > There seems to be a difference between conn.commit() and > cur.execute('commit'), which leaves the connection in a different state. Yes, if a connection library offers a way to commit/roll back, it's usually best to use that. > However, for my purposes, this is academic. > > The main lesson I have learned is that you should always issue a commit > after any logical set of SQL statements, even if they are only SELECTs, > otherwise the locks are not released. Correct. Every time you use any database, you should think in terms of units of work, which correspond precisely to transactions. ChrisA