From cd0fcfae1b134b9076487f10ff8e6dac1ccdb776 Mon Sep 17 00:00:00 2001 From: hjp Date: Sun, 17 Jun 2007 21:40:04 +0000 Subject: [PATCH] Added database connection --- lib/Simba/CA.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/Simba/CA.pm b/lib/Simba/CA.pm index 4c2682b..55b69ac 100644 --- a/lib/Simba/CA.pm +++ b/lib/Simba/CA.pm @@ -30,6 +30,26 @@ sub new { $self->{unknown_gid} = 65533; $self->{fh_log} = exists($opt->{fh_log}) ? $opt->{fh_log} : \*STDERR; $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 = ; + close(FN); + my @cred = split(/[\s\n]+/, $line); + $self->{dbh} = DBI->connect(@cred, + { AutoCommit => 0, + PrintError => 1, + RaiseError => 1 + } + ); + } return $self; }