Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2015-07-04 22:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls