Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51779
| Return-Path | <ian.g.kelly@gmail.com> |
|---|---|
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'ideally': 0.04; 'importing': 0.05; 'insert': 0.05; 'explicit': 0.07; 'cursor': 0.09; 'messing': 0.09; 'grows.': 0.16; 'imports': 0.16; 'invoking': 0.16; 'opened.': 0.16; 'personally,': 0.16; 'pulling': 0.16; 'singleton': 0.16; 'temp': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'module': 0.19; 'commit': 0.19; 'replacing': 0.19; 'thu,': 0.19; 'import': 0.22; 'aug': 0.22; 'putting': 0.22; 'creating': 0.23; 'earlier': 0.24; 'class.': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'probably': 0.32; 'another': 0.32; 'table': 0.34; 'sense': 0.34; "i'd": 0.34; 'agree': 0.35; 'connection': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'application': 0.37; 'level': 0.37; 'connections': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'simply': 0.61; 'first': 0.61; 'needing': 0.65; 'fact,': 0.69; 'potentially': 0.81; 'opens': 0.91; 'step.': 0.91; 'subject:Best': 0.91; 'thing,': 0.91; 'connection,': 0.95; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=cT4WfJtWDktfKAecvTnyYABOgL8aKCdL9wPyySDCDEs=; b=HBcKFpYOa45PqdcN0ZsOcsJ9e/fpTyoZHKJBuvi2Zo8P9+YmD1e94BiAoEpD7cEPKi C6CXbxJKAbQuhngPMC7YiFe+2ftToO+ETSOyvXygTcv5wdTm7a7V0zV+KLCS9//LybIj zbz3eIbFFNZocbVbZZDnE2XGI0YpnrLLJcLNcM66ElT/KesHG8o5rbHAsDZay6n1sxFJ SAnoGDJDbH6t4ajtQzfJ1lGeP5kdENtlc3uAzRAXLEDSxPkDoe63EDebB1rAPOx3yQrL +3UPbx6P7ceNVT+Y5pS9zC/ZdteC9qnKHzWb311U3PJzha3GKwm8nV8OrzeEhheOlHsb StaA== |
| X-Received | by 10.58.34.178 with SMTP id a18mr1267082vej.86.1375406611062; Thu, 01 Aug 2013 18:23:31 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <k70mv8t0lodtb23ti0ka6qv17fggb4ev5s@4ax.com> |
| References | <assp.0925de7e70.719ac7ca4c274c4c884b809e5abd887c@exch.activenetwerx.com> <k70mv8t0lodtb23ti0ka6qv17fggb4ev5s@4ax.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Thu, 1 Aug 2013 19:22:51 -0600 |
| Subject | Re: Best practice for connections and cursors |
| To | Python <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 <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.103.1375406614.1251.python-list@python.org> (permalink) |
| Lines | 29 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1375406614 news.xs4all.nl 15933 [2001:888:2000:d::a6]:49148 |
| X-Complaints-To | abuse@xs4all.nl |
| Path | csiph.com!usenet.pasdenom.info!news.stben.net!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
| Xref | csiph.com comp.lang.python:51779 |
Show key headers only | View raw
On Thu, Aug 1, 2013 at 6:49 PM, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote: > On Thu, 1 Aug 2013 15:05:08 +0000, "Joseph L. Casale" > <jcasale@activenetwerx.com> declaimed the following: > >> >>As the module opens a connection, wherever I import it I call a commit against >>the connection after invoking any methods that insert or change data. >> > > You probably should NOT be opening connections /during/ the import > operation... For one thing, if it is a module level connection, multiple > imports are replacing earlier connections with their fresh one. That's not true. Multiple imports of the same module will only execute the module-level code the first time. I agree though that simply importing the module should not trigger a connection to be opened. That should be an explicit step. Speaking to the OP: personally, I don't like the approach of putting data access methods at the module level to begin with. I'd rather use a class. Just because it makes sense to have a singleton connection now doesn't mean it will always make sense as your application grows. In fact, the conflict you describe where one cursor is interfering with another cursor suggests that you may already be at the point of needing multiple connections. The operation that is creating a temp table and messing things up should ideally be pulling an unused connection from a pool, so as to avoid potentially contaminating a connection that may already be in use elsewhere in the code.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Best practice for connections and cursors Ian Kelly <ian.g.kelly@gmail.com> - 2013-08-01 19:22 -0600
csiph-web