Most applications connect to the database with one set of credentials,
regardless of the user accessing the pages. The current pooling model
works very well in this situation.

My application must implement per-user connections to the database,
where each user will have their own credentials for the database.

It is simple enough to have web2py to establish a connection on each
page load for the users, the difficulty lies with leaving persistent
connections open between page loads. The simplest way I have found to
do this is by making a SQLDB with pool_size=1 for each user.  The
problem with this method is that the users connection will stay open
after they logout.

I know it's possible to manage the connection pool by manipulating
SQLDB._connection_pools externally from my app (say in
auth.settings.logout_onlogout), however I would prefer to do something
that I know won't break with future updates.

So, community, I ask you, how should I be implementing per-user
persistent database connections with web2py?

Reply via email to