[Dbix-class] Multiple connections
Hernan Lopes
hernanlopes at gmail.com
Thu Jan 16 11:47:40 GMT 2014
i guess you are using catalyst dbix models.
dont forget its perl, that means you can create an $app instance to be used
by catalyst. Your models dont need and should not be tied to your web
framework.
what i am saying is, create Your::App module and make it connect to
multiple databases. Create them with dbicdump:
dbicdump -o dump_directory=3D./lib \
-o components=3D'["InflateColumn::DateTime"]' \ <-- *** nao obrigator=
io
-o debug=3D1 \
My::Schema \
'dbi:Pg:dbname=3Dfoo' \
myuser \
mypassword
and make them connect:
use lib ( "./lib" );
use DBSchema;
my $schema =3D DBSchema->connect('dbi:Pg:dbname=3Dsaude', 'hernan', '12=
3');
my $medico =3D $schema->resultset('Medico')->find({ id =3D> 1});
print $medico->name;
Add as many dbs you need.. make catalyst use your $app instance which
connects to multiple dbs
On Thu, Jan 16, 2014 at 9:06 AM, Dave Howorth <dhoworth at mrc-lmb.cam.ac.uk>w=
rote:
> Is there a good (authoritative?) description of how DBIx::Class manages
> database connections? Including whatever is done by other packages
> underneath.
>
> I think I need to make two connections to the same MySQL database with
> different settings of the mysql_enable_utf8 option. But calling
> connection twice seems to result in a single connection.
>
> Thanks, Dave
>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20140116/153=
bd278/attachment.htm
More information about the DBIx-Class
mailing list