Re: Database Connection Lifetime

Christian Boos <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
Rich Shepard wrote:
>    In our approximate reasoning models data are stored in sqlite3 databases
> (one per model). Is it better to open a connection to the database when the
> model is opened (and close it when the model is closed) or open and close
> the connection each time data are to be written or retrieved from the
> database?
>
>    Are there any standards or Best Programming Practices for this?
>   

I dont know whether that's a "Best Practice", but from our usage in 
Trac, it looks like keeping the connection objects alive is not a 
problem. Quite the contrary, this seems to improve the behavior of 
concurrent requests by reducing the likeliness of database locks, though 
I don't fully understand the reason for that.

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