[Dancer-users] Using persistent DB connections in Dancer::Tutorial

Gurunandan Bhat gbhat at pobox.com
Sat Jan 8 10:18:11 CET 2011

If I rewrite connect_db as:

my $dbh;
sub connect_db {

    if (! defined $dbh) {
        $dbh = DBI->connect("dbi:SQLite:dbname=".setting('database')) or
            die $DBI::errstr;
    return $dbh;

will the application use a single connection for all connections under all
perl webservers (in-built, mod_perl, Starman, Twiggy etc.).
If that is true, a line to that effect in an appropriate place in the
tutorial would emphasize the persistent features of the solution.

Also, are any hooks run when the application instance is destroyed? If there
are, implementing a graceful closing of open DB connection(s) might provide
a valuable lesson in the Tutorial.

Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20110108/eb73560d/attachment.htm>

More information about the Dancer-users mailing list