[Dbix-class] multiple database connection

Jorge Gonzalez jorge.gonzalez at daikon.es
Fri Oct 21 16:08:38 GMT 2011


You don't specify if they are distinct DBs or you want to have some kind 
of high availability.

If they are distinct DBs I'd say the easiest (canonical?) way would to 
define two different models, say MyApp::Model::DB1 and MyApp::Model::DB2 
and configure each one separately. When you want to extract or 
manipulate data, you

That's the way I have two simultaneous connections in my app, though one 
is MySQL and the other is Oracle.

Regards
J.

El 21/10/11 16:52, Roland Philibert escribió:
> Hi all,
> Could anybody send me an example on how to connect multiple databases
> using DBIC::Schema?
>
> I have:
>
> package MyApp::Model::DB;
>
> use strict;
> use base 'Catalyst::Model::DBIC::Schema';
>
> __PACKAGE__->config(
>      schema_class =>  'MyApp::Schema',
>
>      connect_info =>  {
>          dsn =>  'dbi:mysql:database=db1:host=host1',
>          user =>  'root',
>          password =>  'root',
>      }
> );
>
> And I need to connect to another mysql db (db2) under a different host
> (host2)
>
> Thank you all.
>
> R.
>
>
>
>
> ---
> Aptina (UK) Limited, Century Court, Millennium Way, Bracknell, Berkshire, RG12 2XT. Registered in England No. 06570543.
>
> This e-mail and any attachments contain confidential information and are solely for the review and use of the intended recipient. If you have received this e-mail in error, please notify the sender and destroy this e-mail and any copies.
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk




More information about the DBIx-Class mailing list