We don't bite newbies here... much | |
PerlMonks |
Re: Re: using multiple packages w/1 database connectionby tachyon (Chancellor) |
on Sep 22, 2003 at 07:41 UTC ( [id://293095]=note: print w/replies, xml ) | Need Help?? |
Pet peeve. If you don't religiously disconnect from the DB what CAN happen is that when the script completes $dbh gets undeffed BUT the underlying connection MAY potentially remain until it times out. Although the DBI DESTROY method should be called on script exit and this should call disconnect we have practical experince that this is not always the case. Also if you are using transactions the Commit/Rollback behaviour on disconnect is not defined so you might wish to add a commit to the end block as well to finalise everything. On MySQL you get a default limit of 100 max_connections and a timeout of 8 hours. Result: Run a script that fails to disconnect more than 100 times in 8 hours and you will potentially use up all your available connections. At this point the DB connect will error out every time until an old connection times out. I think is is failry sound practice to code the connect like this, with the disconnect in an END block immediately below. It makes sure it happens.
cheers tachyon s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
In Section
Seekers of Perl Wisdom
|
|