[Dbix-class] Setting up database connection at run-time

Juan Camacho jc5826 at gmail.com
Sun Jan 13 19:10:49 GMT 2008


This question is somewhere between DBix::Class and Catalyst. I'm
starting a catalyst application where each account will have their own
database. The schema is identical for each database and there is one
master database where username and database mappings are stored.
After the user logs in I'm able to determine which database the user
will interact with and I'm setting the $c->session->{database}
accordingly.

I have a working catalyst Model code version (attached) where I'm
setting up the connection at run-time -- code is mostly hacked from
Catalyst::Model::DBIC::Schema. I wonder if there is a better way of
doing this.  I read and re-read the DBIx::Class::Schema documentation
but couldn't figure out a more elegant solution. I would appreciate
some feedback on other solutions -- especially ones where I'm not so
tightly coupled to Catalyst.

Thanks, Juan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DB.pm
Type: application/octet-stream
Size: 1446 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20080113/ca=
3cfb1d/DB.obj


More information about the DBIx-Class mailing list