Re: Closing Connections between Queries

Rich Shepard <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
On Sun, 16 Sep 2007, Kyle Stevens wrote:

> Is it best to open and close the connection on each query, or should the
> connection remain open throughout the life of the application?  Also, does
> the answer differ depending on the DBMS used or whether it is a single
> user or multi user environment?

Kyle,

   Open the connection when the application is invoked and close it when the
application is shut down. After each write you can issue a con.commit() to
flush the memory buffer to disk to ensure data entegrity, but there's no
value to the overhead of opening and closing connections all the time.

   This holds true regardless of the back end and how many users may be
accessing it.

   From the little I've seen of VB applications, they're not good examples of
how to do anything. We've ported one from VB/C to Python/wxPython with the
core libraries cleaned, tighened, and improved but remaining in C.

Rich

-- 
Richard B. Shepard, Ph.D.               |    The Environmental Permitting
Applied Ecosystem Services, Inc.        |         Accelerators(TM)
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.