From: Bill Erickson Date: Fri, 18 Dec 2015 16:34:50 +0000 (-0500) Subject: JBAS-980 auth linking repairs/consistency X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1c330f3ac50aa9ca2cb5fb7e1fbfc27a14d789f0;p=working%2FEvergreen.git JBAS-980 auth linking repairs/consistency 1. Use consistent DB connection logic -- removes a lot of unnecessary DB connection settings logic. 2. Set log traces via OSRF_LOG_CLIENT Signed-off-by: Bill Erickson --- diff --git a/KCLS/linking/authority_authority_linker.pl b/KCLS/linking/authority_authority_linker.pl index 96dd9b6921..97e6f010c8 100755 --- a/KCLS/linking/authority_authority_linker.pl +++ b/KCLS/linking/authority_authority_linker.pl @@ -17,6 +17,8 @@ use OpenILS::Utils::Normalize; use Data::Dumper; use Pod::Usage qw/ pod2usage /; +$ENV{OSRF_LOG_CLIENT} = 1; + $Data::Dumper::Indent = 0; MARC::Charset->assume_unicode(1); @@ -45,10 +47,10 @@ my ($start_id, $end_id); my $bootstrap = '/openils/conf/opensrf_core.xml'; my @records; my $verbose; -my $db_host = 'localhost'; -my $db_port = '5432'; -my $db_user = 'evergreen'; -my $db_pass = 'evergreen'; +my $db_host = $ENV{PGHOST} || 'localhost'; +my $db_port = $ENV{PGPORT} || '5432'; +my $db_user = $ENV{PGDATABASE} || 'evergreen'; +my $db_pass = $ENV{PGPASSWORD}; my %options; my $result = GetOptions( diff --git a/KCLS/linking/authority_authority_linker_batcher.pl b/KCLS/linking/authority_authority_linker_batcher.pl index 10521746b7..4437097e9f 100755 --- a/KCLS/linking/authority_authority_linker_batcher.pl +++ b/KCLS/linking/authority_authority_linker_batcher.pl @@ -51,10 +51,10 @@ use OpenSRF::System; my $batch_size = 1000; my $lower_bound = 0; -my $db_host = 'localhost'; -my $db_port = '5432'; -my $db_user = 'evergreen'; -my $db_pass = 'evergreen'; +my $db_host = $ENV{PGHOST} || 'localhost'; +my $db_port = $ENV{PGPORT} || '5432'; +my $db_user = $ENV{PGDATABASE} || 'evergreen'; +my $db_pass = $ENV{PGPASSWORD}; my $result = GetOptions( "lower-bound=i" => \$lower_bound, diff --git a/KCLS/linking/authority_control_fields.pl b/KCLS/linking/authority_control_fields.pl index 80dea4efcb..bce6a37599 100755 --- a/KCLS/linking/authority_control_fields.pl +++ b/KCLS/linking/authority_control_fields.pl @@ -31,6 +31,8 @@ use Data::Dumper; use Pod::Usage qw/ pod2usage /; use DateTime; +$ENV{OSRF_LOG_CLIENT} = 1; + $Data::Dumper::Indent = 0; MARC::Charset->assume_unicode(1); @@ -40,6 +42,10 @@ my $input_file =''; my $bootstrap = '/openils/conf/opensrf_core.xml'; my @records; my $verbose = 0; +my $db_host = $ENV{PGHOST} || 'localhost'; +my $db_port = $ENV{PGPORT} || '5432'; +my $db_user = $ENV{PGDATABASE} || 'evergreen'; +my $db_pass = $ENV{PGPASSWORD}; my %options; my $result = GetOptions( @@ -52,7 +58,11 @@ my $result = GetOptions( 'end_id=i' => \$end_id, 'days_back=i' => \$days_back, 'file=s' => \$input_file, - 'verbose' => \$verbose + 'verbose' => \$verbose, + "db-host=s" => \$db_host, + "db-user=s" => \$db_user, + "db-pass=s" => \$db_pass, + "db-port=s" => \$db_port ); sub announce { @@ -96,27 +106,16 @@ if ($start_id and $end_id) { if (defined $days_back) { @records=(); -# Grab DB information from local settings -my $sc = OpenSRF::Utils::SettingsClient->new; -my $db_driver = $sc->config_value( apps => 'open-ils.storage' => app_settings => databases => 'driver' ); -my $db_host = $sc->config_value( apps => 'open-ils.storage' => app_settings => databases => database => 'host' ); -my $db_port = $sc->config_value( apps => 'open-ils.storage' => app_settings => databases => database => 'port' ); -my $db_name = $sc->config_value( apps => 'open-ils.storage' => app_settings => databases => database => 'db' ); - -if (!$db_name) { - $db_name = $sc->config_value( reporter => setup => database => 'name' ); - print STDERR "WARN: is a deprecated setting for database name. For future compatibility, you should use instead." if $db_name; -} -my $db_user = $sc->config_value( apps => 'open-ils.storage' => app_settings => databases => database => 'user' ); -my $db_pw = $sc->config_value( apps => 'open-ils.storage' => app_settings => databases => database => 'pw' ); - -die "Unable to retrieve database connection information from the settings server" unless ($db_driver && $db_host && $db_port && $db_name && $db_user); - -my $dsn = "dbi:" . $db_driver . ":dbname=" . $db_name .';host=' . $db_host . ';port=' . $db_port; -my $dbh = DBI->connect($dsn,$db_user,$db_pw, {AutoCommit => 1, pg_enable_utf8 => 1, RaiseError => 1}) or die "database connection error"; +my $dsn = "dbi:Pg:database=evergreen;host=$db_host;port=$db_port"; +my $dbh = DBI->connect($dsn, $db_user, $db_pass); # SQL Used to gather a list of ID's -my $idstatement = $dbh->prepare("SELECT DISTINCT(id) AS id FROM biblio.record_entry where (date(create_date) = date(now()) or date(edit_date) = date((NOW() - '$days_back day'::interval)))"); +my $idstatement = $dbh->prepare(<execute(); diff --git a/KCLS/linking/authority_control_fields_batcher.pl b/KCLS/linking/authority_control_fields_batcher.pl index a24fe2f628..a546fd3172 100755 --- a/KCLS/linking/authority_control_fields_batcher.pl +++ b/KCLS/linking/authority_control_fields_batcher.pl @@ -51,10 +51,11 @@ use Getopt::Long; my $batch_size = 5000; my $lower_bound = 0; -my $db_host = 'localhost'; -my $db_port = '5432'; -my $db_user = 'evergreen'; -my $db_pass = 'evergreen'; +my $db_host = $ENV{PGHOST} || 'localhost'; +my $db_port = $ENV{PGPORT} || '5432'; +my $db_user = $ENV{PGDATABASE} || 'evergreen'; +my $db_pass = $ENV{PGPASSWORD}; +my $db_pass; my $result = GetOptions("lower-bound=i" => \$lower_bound, "batch-size=i" => \$batch_size, diff --git a/KCLS/linking/authority_control_fields_batcher_all_exported.pl b/KCLS/linking/authority_control_fields_batcher_all_exported.pl index e2e3605d03..009343ec11 100755 --- a/KCLS/linking/authority_control_fields_batcher_all_exported.pl +++ b/KCLS/linking/authority_control_fields_batcher_all_exported.pl @@ -6,10 +6,10 @@ use Getopt::Long; use DBI; my $batch_size = 500; -my $db_host = 'localhost'; -my $db_port = '5432'; -my $db_user = 'evergreen'; -my $db_pass = 'evergreen'; +my $db_host = $ENV{PGHOST} || 'localhost'; +my $db_port = $ENV{PGPORT} || '5432'; +my $db_user = $ENV{PGDATABASE} || 'evergreen'; +my $db_pass = $ENV{PGPASSWORD}; my $base_path = '/var/KCLS_AUTH'; my $result = GetOptions(