Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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()); }); });

Replies are listed 'Best First'.
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2016-12-05 21:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (94 votes). Check out past polls.