[dancer-users] dancer-users Digest, Vol 66, Issue 30

Andrew Beverley andy at andybev.com
Tue Aug 25 15:28:05 BST 2015

On Tue, 2015-08-25 at 15:20 +0100, Dancer New wrote:
> > > The problem I have now was the database connection in 'before hook' (
> > > setting user context) and the db connection in the route for actual query
> > > seems two different db connections. So the database doesn't know they are
> > > from the same user request and therefore doesn't return the right results.
> > 
> > It sounds like you are initiating a new database connection for each page
> > request? If so, that's very expensive, and not likely to be very scalable.
> > 
> I  would like to know how to make one db connection and use it in all
> requests. where to store  the database handler?

You could try this:


That's not going to work if you need a different database connection per user
though, in which case you could maybe store the connection handle in the user's


More information about the dancer-users mailing list