Search code examples
zodb

Is it necessary to close ZODB connections after only reading data


I am using ZODB for my python object persistence. I am using web2py as a framework.

The ZODB database I am using is accessed only for reads. I have written the code for opening the database inside my models. The connection.root() object is then cached in RAM so it stays there for other requests.

My question is, is it necessary to close a ZODB database if it is used only for read access and there are no pending writes?


Solution

  • No you don't need to close it. Each open connection does consume a little memory etc, but it sounds like you aren't going to have thousands of them anyway, just one per web2py process