From: Chris Sharp Date: Fri, 24 Feb 2012 13:03:52 +0000 (-0500) Subject: adding little utility to ease tracking down users by ID X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=158aa800a0e6495c99098ee0208f17d9a6bd9673;p=evergreen%2Fpines.git adding little utility to ease tracking down users by ID --- diff --git a/Open-ILS/examples/pines-examples/who_is.pl b/Open-ILS/examples/pines-examples/who_is.pl new file mode 100755 index 0000000000..462ed78c48 --- /dev/null +++ b/Open-ILS/examples/pines-examples/who_is.pl @@ -0,0 +1,65 @@ +#!/usr/bin/perl -w +# +# Copyright (C)2010-2012 Georgia Public Library Service +# Chris Sharp +# +=pod + +A utility to easily discover a patron's name and active card number +from the command line. It requires the following: +1) a direct connection to the database you're trying to query +2) Perl DBI and DBD::Pg packages installed (libdbi-perl and + libdbd-pg-perl packages on Debian/Ubuntu) + +The main use case for this is to provide a non-technical end user +(e.g., a library administrator or helpdesk manager) with a non-SQL +way to get the active card barcode and full name of a user from an +Evergreen user ID gathered from displayed columns in the staff client +for a circulation or hold object. + +Usage: + + perl who_is.pl + +=cut +use strict; +use DBI; + +my $uID; +my $query; +my $db_name = "evergreen"; +my $db_host = "myhost"; +my $db_user = "evergreen"; +my $db_pass = "mypassword"; + + +print "Please enter the user ID: "; +chomp($uID = ); + +$query = <connect("DBI:Pg:dbname=$db_name;host=$db_host", "$db_user", "$db_pass", {'RaiseError' => 1}); + + +# execute SELECT query +my $sth = $dbh->prepare("$query"); +$sth->execute(); +my ($cdBarcode, $first_name, $middle_name, $last_name); + +# iterate through resultset +# print values +my $ref = $sth->bind_columns(\($cdBarcode, $first_name, $middle_name, $last_name)); +while ($sth->fetch) { + print "User $uID has barcode $cdBarcode and is named $first_name $middle_name $last_name.\n"; +} + +# clean up +$dbh->disconnect(); +