Added database connection
This commit is contained in:
parent
14cd9fc2fb
commit
cd0fcfae1b
|
@ -30,6 +30,26 @@ sub new {
|
||||||
$self->{unknown_gid} = 65533;
|
$self->{unknown_gid} = 65533;
|
||||||
$self->{fh_log} = exists($opt->{fh_log}) ? $opt->{fh_log} : \*STDERR;
|
$self->{fh_log} = exists($opt->{fh_log}) ? $opt->{fh_log} : \*STDERR;
|
||||||
$self->{log_level} = 99;
|
$self->{log_level} = 99;
|
||||||
|
if ($opt->{dbi}) {
|
||||||
|
$self->{dbh} = DBI->connect(@{ $opt->{dbi} },
|
||||||
|
{ AutoCommit => 0,
|
||||||
|
PrintError => 1,
|
||||||
|
RaiseError => 1
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} elsif ($opt->{dbi_file}) {
|
||||||
|
my $fn = $opt->{dbi_file};
|
||||||
|
open(FN, "<$fn") or die "cannot open $fn: $!";
|
||||||
|
my $line = <FN>;
|
||||||
|
close(FN);
|
||||||
|
my @cred = split(/[\s\n]+/, $line);
|
||||||
|
$self->{dbh} = DBI->connect(@cred,
|
||||||
|
{ AutoCommit => 0,
|
||||||
|
PrintError => 1,
|
||||||
|
RaiseError => 1
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue