
Dancer2::plugin::database provides an easy way to obtain a connected dbi database handle by simply calling the database keyword within your dancer2 application
the module returns a dancer::plugin::database::core::handle object, which is a subclass of dbi's `dbi::db' connection handle object, so it does everything you'd expect to do with dbi, but also adds a few convenience methods.
it takes care of ensuring that the database handle is still connected and valid. if the handle was last asked for more than `connection_check_threshold' seconds ago, it will check that the connection is still alive, using either the `$dbh->ping' method if the dbd driver supports it, or performing a simple no-op query against the database if not. if the connection has gone away, a new connection will be obtained and returned. this avoids any problems for a long-running script where the connection to the database might go away.
care is taken that handles are not shared across processes/threads, so this should be thread-safe with no issues with transactions etc.