Using SQL for Patron Card Expiration Reminders For Norcal IUG – Nov. 20, 2015 At the Berkeley Public Library
MARINet is… A consortium of 7 public and 2 academic libraries in Marin County. 152k patrons 531k bibs 1.2m items 3 Fulltime ILS staff +
Roles! Sys Admin, System Librarian, Office Manager
“SQL” means Structured Query Language SELECT * from table where table.column = ‘stuff’ It has it’s own syntax, etc.
Familiar?
In this context… “SQL” means getting data out of Sierra Using software Using a Sierra Login (application SQL) Open port 1032 to db server if needed
Expiring cards… In July, 2014, 42% of our public library cards were expired. (We delete inactive cards after 3 years.) In Sept we started sending out “Your card expires next month” s to public library patrons. Now, 34% of our public library are expired. (9% absolute drop, or a decrease of 19%!)
Renewing cards… The number of cards which expire in any given month seems to have gone down (since the s) by 10 to 15%.
Why it matters… People travelling are caught out by card expiration. Encore does not list card expiration on patron account page. Ebook/Eaudiobook users don’t tend to interact with their library records and with staff in the traditional ways.
SQL can… Find the expiring (public) library cards (filter for patron type and home library) for “next month” Find the ones with addresses (85.5%) Retrieve: – Home library – Expiration date – – Barcode (last 5 digits)
The software to start with…
PG Admin III – Database Window
PG Admin III – Query Window
Where to find query samples…
SQL Query Samples
Code sample
Or from the listservs… IUG listserv Sierra listserv
I keep my queries in old text files…
Full of old text…
PG Admin: Results in a text file
Seeing the DB past the SDA
To see the structure of the DB
Running SQL queries with scripting can do much more… Scripting can retrieve the data using SQL queries and store it in text files, even manipulate the data and query again Scripting can generate an for each patron using the SQL data Scripting can the data (if pointed at an server) Scripting can be scheduled…
People are using… Mostly PHP Some Perl Some Python Languages that don’t start with “P”?
MARINet: Perl Old, old, old programming language What we used to use for Expect scripts Fairly easy to write and maintain, “just like English” Caveat: SQL connector for Perl requires a Linux box (old PC, free software)
Modify the date… Modify the date first Supplying range of dates for SQL query
Then run the thing… “perl expcards.pl”
5 minutes Search 152,000 records, find 3,000 Search again for address, then for phone numbers (display data for patron update) Sends the s out Runs Command line (we have not scheduled it)
It came from the library… The patron’s home library determines “reply to” address
Sample
Get the script?
Nothing to fear…
Other things we use SQL for: Quick queries where it works better than Create Lists (Link+, How many items, ) Link+ overdues Link+ daily hold and checkout counts ( ed) Find empty volume records Find orphaned items (volume records)
…and… Find old frozen holds (and the patrons that we’re going to delete them) Bibs with holds webpage (2x daily) Data upload to Ebsco for NoveList Looking for more uses
The End – Questions? Dan McMahon