X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=mig-bin%2FMig.pm;h=f1b97f269922970833e607db7ffe7639f014412d;hp=46aa1d1866fb2f154b83abeaae543c63d6fa8417;hb=d3bf56fcd9351c4ef45b5527d929228b6663ecaf;hpb=91f3fc3c89d088788f7064bc06764ff83a40e607 diff --git a/mig-bin/Mig.pm b/mig-bin/Mig.pm index 46aa1d1..f1b97f2 100644 --- a/mig-bin/Mig.pm +++ b/mig-bin/Mig.pm @@ -19,14 +19,20 @@ use Env qw( ); sub db_connect { - my $dbh = DBI->connect( + my $dbh; + if ($PGHOST) { + $dbh = DBI->connect( "dbi:Pg:host=$PGHOST;dbname=$PGDATABASE;port=$PGPORT" ,$PGUSER ,undef - ) || die "Unable to connect to $PGHOST:$PGPORT:$PGDATABASE:$PGUSER : $!\n"; + ) || die "Unable to connect to $PGHOST:$PGPORT:$PGDATABASE:$PGUSER : $!\n"; + } else { + $dbh = DBI->connect("dbi:Pg:dbname=$PGDATABASE", "", "") || die "Unable to connect to $PGDATABASE : $!\n"; + } $dbh->do("SET search_path TO $MIGSCHEMA, evergreen, pg_catalog, public"); return $dbh; } + sub db_disconnect { my $dbh = shift; $dbh->disconnect;