On Fri, Nov 14, 2014 at 7:58 AM, Vincent Veyron <vv.li...@wanadoo.fr> wrote:

> If I understand correctly, I could also use Apache::DBI and a persistent
> connection for a similar result, modulo what you wrote in an earlier
> message regarding the connection being more explicit (which I don't quite
> grasp, I'll have to study on that)?


Right. Apache::DBI overrides DBI->connect() when loaded so that a normal
connect() call gets a cached handle if available.

What you're doing here looks fine. If you ever switch off AutoCommit in
your code, I'd suggest adding a cleanup handler that checks if the handle
is not currently in AutoCommit mode, and if not, issues a rollback and
switches it to AutoCommit. That protects against an exception leaving your
database handle in a bad state. (Apache::DBI tries to do that
automatically, but it's not very smart about it. It only happens if you
have AutoCommit off when you connect.)

- Perrin

Reply via email to