[Dbix-class] Multiple DBs, one Schema to rule them all

Rob Kinyon rob.kinyon at gmail.com
Sat Feb 12 16:03:31 GMT 2011


On Fri, Feb 11, 2011 at 20:20, Trevor Leffler <tleffler at uw.edu> wrote:
> Hello,
>
> I am investigating whether DBIC has support for switching between logical
> databases (ala 'use db1; ...; use db2; ...;').  I've a situation where there
> exist many cloned databases (same DDL), one per customer. The current model
> is that all customers share the same front-end, and it switches between DBs
> as needed.  I would like to avoid the following: multiple open connections
> per app process, multiple MyDB::Schema objects, server hups upon customer
> adds/drops, etc.
>
> The very reasonable suggestion to combine all of the client databases into
> one is being considered, so please let's not get side-tracked by that line
> of thought, thanks. :)
>
> So... how might I have my Schema issue a 'use $db' prior to any queries?  Or
> perhaps are there other solutions to how one could have multiple DB clones
> while avoiding the code and connection scaling issues?

Have you considered $schema->storage->dbh_do("use $db") ?

Rob



More information about the DBIx-Class mailing list