Connect as user sipwise to ngcp database.

From: Michael Prokop <mprokop@sipwise.com>
2.6
Michael Prokop 14 years ago
parent 31c5b5bd54
commit 03946ef229

2
debian/control vendored

@ -8,7 +8,7 @@ Homepage: http://sipwise.com/
Package: ngcp-db-schema
Architecture: all
Depends: ${misc:Depends}
Depends: ${misc:Depends}, libconfig-tiny-perl
Description: database schema for Sipwise's NGCP platform
This package provides the database schema for Sipwise's NGCP
platform.

@ -5,6 +5,7 @@ use warnings;
use DBI;
use Getopt::Long;
use Pod::Usage;
use Config::Tiny;
my $dbhost = 'localhost';
my $dbname = 'ngcp';
@ -31,7 +32,18 @@ pod2usage(-exitval => 2, -verbose => 2) if $man;
pod2usage(2) if !defined $revision;
pod2usage(2) if !defined $schema;
my $dbh = DBI->connect("dbi:mysql:dbname=$dbname;host=$dbhost")
# connect as user sipwise to DB
my $Config = Config::Tiny->read('/etc/mysql/sipwise.cnf') or die "Could not read /etc/mysql/sipwise.cnf";
my $dbuser = 'sipwise';
my $dbpwd = $Config->{_}->{SIPWISE_DB_PASSWORD};
if (!defined $dbpwd) {
die "Couldn't identify password for user sipwise to connect to database.";
}
$dbpwd =~ s/^['"](.*)['"]$/$1/g; # get rid of possibly surrounding quotes
my $dbh = DBI->connect("dbi:mysql:dbname=$dbname;host=$dbhost", $dbuser, $dbpwd)
or die "Couldn't connect to database: " . DBI->errstr;
$schema = $dbh->quote_identifier($schema);

Loading…
Cancel
Save