[Dbix-class] Multiple connections

Dave Howorth dhoworth at mrc-lmb.cam.ac.uk
Thu Jan 16 17:17:08 GMT 2014


Dave Howorth wrote:
> Apparently I still don't understand enough to use this effectively. If I do
> 
>     my $schemaw = TDB::Schema->connect($dsn, $user, $password);
> 
>     $dbi_params = {
>         mysql_enable_utf8 => 1,
>         on_connect_do     => "SET NAMES 'utf8'",
>     };
> 
>     my $schemau = TDB::Schema->connect($dsn, $user, $password,
>                                        $dbi_params);
> 
> things work, but I don't have the dsn etc immediately available in the
> place where I need to make the second call and if I replace the second
> connect with
> 
>     my $schemau = $schemaw->clone($dbi_params);
> 
> things don't work. Is there some way to use clone? Or is there some way
> to retrieve the connection info so I can reuse it?

So by reading the code, I discovered that it is possible to call
connect_info with no argument and get the current info in return, at
least for DBIx::Class::Storage::DBI. If I do that, then I can haz
working kode.

However, AFAICT the docs do not describe this use case for
connect_info(). The docs don't seem to mention a return value at all. So
am I safe in using it this way, or may it break in the future?

> I suppose I'm still interested in the answer to my original question:
> 
> Is there a good (authoritative?) description of how DBIx::Class manages
> database connections? Including whatever is done by other packages
> underneath.



More information about the DBIx-Class mailing list