closing database connections

dustin lee dlee at rightnow.com
Fri Jan 23 11:38:32 EST 2004


Over the years I've gotten out of the habit of explicitly closing file
objects (whether for reading or writing) since the right thing always
seems to happen auto-magically (e.g. files get written to disk with no
missing data).  I've recently started do the same thing with database
connections.  I'm wondering if anyone has had trouble with this sort
of "lazy" programming style.  My assumption is the the database
connection will get closed auto-magically when the interpreter closes.
 I'd be interested to hear if any one has been bitten by not
explicitly closing database connections and under what cirumstances. 
My main fear is that I will "run out of" database connections or in
some other way adversely affect server performance.  I'm using recent
versions of both mysql and oracle.

Thoughts?

dustin

ps.  If someone wants to try to talk me into explicitly closing files
I'd be interested to hear wisdom on that as well.



More information about the Python-list mailing list