Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51773
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!eweka.nl!hq-usenetpeers.eweka.nl!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.017 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.01; 'insert': 0.05; 'module)': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; '>the': 0.16; 'imports': 0.16; 'invoking': 0.16; 'message- id:@4ax.com': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'module': 0.19; 'commit': 0.19; 'replacing': 0.19; 'thu,': 0.19; 'import': 0.22; 'aug': 0.22; 'url:home': 0.24; 'earlier': 0.24; 'header:X-Complaints-To:1': 0.27; 'invoke': 0.31; 'probably': 0.32; 'skip:d 20': 0.34; 'connection': 0.35; 'something': 0.35; 'charset:us-ascii': 0.36; 'should': 0.36; 'level': 0.37; 'received:76': 0.38; 'connections': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'do:': 0.91; 'opens': 0.91; 'resolved.': 0.91; 'subject:Best': 0.91; 'thing,': 0.91; 'connection,': 0.95; '2013': 0.98 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
| Subject | Re: Best practice for connections and cursors |
| Date | Thu, 01 Aug 2013 20:49:57 -0400 |
| Organization | IISS Elusive Unicorn |
| References | <assp.0925de7e70.719ac7ca4c274c4c884b809e5abd887c@exch.activenetwerx.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | adsl-76-253-109-54.dsl.klmzmi.sbcglobal.net |
| X-Newsreader | Forte Agent 6.00/32.1186 |
| X-No-Archive | YES |
| 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.102.1375404608.1251.python-list@python.org> (permalink) |
| Lines | 40 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1375404608 news.xs4all.nl 15982 [2001:888:2000:d::a6]:58613 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:51773 |
Show key headers only | View raw
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 is -- do NOT do:
-=-=-=-=- (imported module)
...
theCon = db.connection(database)
...
-=-=-=-=-
Instead, use something like
-=-=-=-=-
...
def initialize():
global theCon
theCon = db.connection(database)
...
-=-=-=-=-
and have only one importer invoke
theModule.initialize()
which should take place after all imports have been resolved.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Best practice for connections and cursors Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-08-01 20:49 -0400
csiph-web