Multiple MyLibrary instances

This posting describes how you can use MyLibrary it implement multiple digital library collections and services on the same computer.

As alluded to previously, the technical underpinnings of MyLibrary consists of: 1) a data base, and 2) a set of Perl modules that do input/output against the database. When the Perl modules were first installed the systems administrator was required to edit a file called Config.pm with three values: 1) a DSN — a pointer to the database, 2) a database user name, and 3) a database user name password. The systems administrator then ran a few tests against the modules and installed the modules.

This is all well and good, but it limits MyLibrary to reading and writing to only a single database. What if you have multiple collections? A set of pathfinders? A set of subject pages? A set of course pages? A collection of images or sounds? Each of these collections will have slightly different facet/term combinations, different sets of users, and different sets of librarians. Putting all of these collections into the same database is possible but impractical.

Luckily there is the MyLibrary database schema and a utility called config_mylibrary.pl written by Rob Fox. Used together these files allow you to implement multiple MyLibrary instances. Here’s how:

  1. Create a new database, say, image_library. From a MySQL prompt you would enter create database image_library.
  2. Grant permissions the to database. Again, from a MySQL prompt you would enter GRANT SELECT, UPDATE, DELETE, INSERT ON image_library.* TO 'nobody'@'localhost' IDENTIFIED BY 'nobody';
  3. Initialize the new database. You do this using the database schema found in the MyLibrary distribution. Assuming MySQL you would enter something like this from your shell prompt mysql -uroot -p image_library < mylibrary-mysql-schema.sql
  4. Configure MyLibrary. With root privileges, run config_mylibrary.pl. It will search your file system for a copy of Config.pm. You will then be prompted to create a new configuration. Give your configuration a name, say, IMAGES. Assign the configuration a DSN. Assuming a locally hosted MySQL database, this value will be DBI:mysql:image_library. Assign the configuration a username, the same value used in Step #3. Assign the configuration a password, the same value used in Step #3. Save the configuration and quit config_mylibrary.pl. The result will be an updated version of your Config.pm file complete with the new configuration.

To take advantages of your new configuration you will need to use an (undocumented) MyLibrary method — MyLibrary::Config->instance. Specifically, when you write your Perl script you will need to “require” MyLibrary just like always:

use MyLibrary::Core;

But to use your new configuration, you will need to tell MyLibrary which instance you want to use. To do this add an additional line to your initialization:

MyLibrary::Config->instance( 'IMAGES' );

Thus, the head of your script might look like this:

#!/usr/bin/perl# require
use MyLibrary::Core;

# configure
MyLibrary::Config->instance( 'IMAGES' );

Now, anytime you create, edit, or delete objects in MyLibrary they will get saved to the database named image_library.

By repeating the steps outlines above for each of your digital libraries you will be able to write programs that read and write to various databases without unnecessarily duplicating the MyLibrary Perl modules throughout your file system — easily implemented multiple digital libraries.

Discussion Area - Leave a Comment

You must be logged in to post a comment.