Commit f20add4c authored by Francesc Guasch's avatar Francesc Guasch
Browse files

connect to db when starting

parent 1700eeb5
......@@ -53,14 +53,19 @@ Internal constructor
sub BUILD {
my $self = shift;
$CONNECTOR = $self->connector if $self->connector;
if ( $self->connector ) {
$CONNECTOR = $self->connector
} else {
$CONNECTOR = $self->_connect_dbh();
}
}
sub _connect_dbh {
my $driver= ($CONFIG->{db}->{driver} or 'mysql');;
my $db_user = ($CONFIG->{db}->{user} or getpwnam($>));;
my $db_pass = ($CONFIG->{db}->{password} or undef);
return DBIx::Connector->new("DBI:$driver"
my $db = ( $CONFIG->{db}->{db} or 'ravada' );
return DBIx::Connector->new("DBI:$driver:$db"
,$db_user,$db_pass,{RaiseError => 1
, PrintError=> 0 });
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment