Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51804

RE: Best practice for connections and cursors

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jcasale@activenetwerx.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.021
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'ideally': 0.04; 'cursor': 0.09; 'messing': 0.09; '>in': 0.16; 'debugger.': 0.16; 'grows.': 0.16; 'personally,': 0.16; 'pulling': 0.16; 'received:172.18.0': 0.16; 'singleton': 0.16; 'temp': 0.16; 'code.': 0.18; 'module': 0.19; 'putting': 0.22; 'creating': 0.23; 'header:In-Reply-To:1': 0.27; 'point': 0.28; "doesn't": 0.30; 'code': 0.31; 'another': 0.32; 'running': 0.33; 'table': 0.34; 'sense': 0.34; "i'd": 0.34; 'connection': 0.35; 'charset:us-ascii': 0.36; 'thanks': 0.36; 'should': 0.36; 'application': 0.37; 'level': 0.37; 'to:addr :python-list': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'received:unknown': 0.61; 'needing': 0.65; 'fact,': 0.69; 'potentially': 0.81; 'route': 0.84; 'subject:Best': 0.91
X-Cloudmark-SP-Filtered true
X-Cloudmark-SP-Result v=1.1 cv=PW5KkOyi2N+7koGLNuH5QW2TYwO584XWNobLzFE45Rc= c=1 sm=1 a=CRTDazI5n6YA:10 a=F3_n2MAKYygA:10 a=7PYXob_7ZXMA:10 a=BLceEmwcHowA:10 a=kj9zAlcOel0A:10 a=xqWC_Br6kY4A:10 a=oNw28mxuUhXRB3mVwYQ4Ag==:17 a=bHup-xqeZgwdli8z3wMA:9 a=CjuIK1q_8ugA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117
From "Joseph L. Casale" <jcasale@activenetwerx.com>
To Python <python-list@python.org>
Subject RE: Best practice for connections and cursors
Thread-Topic Best practice for connections and cursors
Thread-Index AQHOjsdwoB2d8GS7N0aIL+r6i2Qjn5mBF6AsgABtAoCAAGC7IA==
Date Fri, 2 Aug 2013 13:10:50 +0000
References <719ac7ca4c274c4c884b809e5abd887c@exch.activenetwerx.com> <k70mv8t0lodtb23ti0ka6qv17fggb4ev5s@4ax.com> <CALwzid=+RaYmFa3bz-ne1VCxEgbc2Lamq4uAWH8E9=7RkXeT7A@mail.gmail.com>
In-Reply-To <CALwzid=+RaYmFa3bz-ne1VCxEgbc2Lamq4uAWH8E9=7RkXeT7A@mail.gmail.com>
Accept-Language en-US
Content-Language en-US
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [172.18.0.200]
Content-Type text/plain; charset="us-ascii"
Content-Transfer-Encoding quoted-printable
MIME-Version 1.0
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.122.1375449150.1251.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1375449150 news.xs4all.nl 16012 [2001:888:2000:d::a6]:47661
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:51804

Show key headers only | View raw


>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.

Appreciate the opinion, it would clean it up to go this route so I will. It turns out
the long delay was only a result of running the code through PyCharms debugger.

Thanks for the suggestion,
jlc

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

RE: Best practice for connections and cursors "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-08-02 13:10 +0000

csiph-web