Re: Closing Connections between Queries
Kyle Stevens <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
Rich Shepard wrote: > 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 > > Thanks for your suggestions. That seems to pretty much answer my question exactly. I'll have to play around a bit to see exactly how it works.