Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: DBIx::Class connection

by Khen1950fx (Canon)
on Jan 03, 2011 at 09:16 UTC ( #880155=note: print w/ replies, xml ) Need Help??

in reply to DBIx::Class connection

I took Your Mother's example and added DBIx::QueryByName::Logger and DBIx::Connector. DBIx::Connector will automatically take care of reconnecting your $dbh. All you have to do is worry about exceptions. If you have Log::Log4perl, then DBIx::QueryByName::Logger will use its get_logger method and utilize Log::Log4perl.

package My::Schema; use strict; use warnings; use base qw/DBIx::Class::Schema/; use DBIx::Connector; use DBIx::QueryByName::Logger; __PACKAGE__->load_classes; my $dsn; my $username; my $password; my %attr; my %extr; my $schema = My::Schema->connect( sub { my $conn = DBI::Connector->new( $dsn, $username, $password, \%attr, \%extr); my $dbh = $conn->dbh; $conn->run( fixup => sub { my $log; &$_->($log = get_logger()); }); });

Comment on Re: DBIx::Class connection
Download Code
Re^2: DBIx::Class connection
by Anonymous Monk on Mar 24, 2013 at 21:55 UTC
    DBI::Connector->new or DBIx::Connector->new

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://880155]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (16)
As of 2015-06-03 18:51 GMT
Find Nodes?
    Voting Booth?

    What kind of chocolate gives you the most pleasure?

    Results (138 votes), past polls