User Tools

Site Tools


old:mysql_processing_using_dbplug

This page is in the 'old' namespace, and was imported from our previous wiki. We recommend checking for more up-to-date information using the search box.

MySQL Processing Using DatabasePlugin

This describes my experience of getting DBPlug to get records for a mysql database.

  • My test mysql is installed on wesson.cs.waikato.ac.nz
  • My greenstone is installed in /research/shaoqun/testing/gsdl/collect/testsql (on Linux).
  • My test database is called gswikidb.
  • My test database table is gw_user.
  • I copied /research/shaoqun/testing/gsdl/etc/packages/example.dbi into the import directory of my collection testsql.
  • This file was modified by setting the following variables:
 $db='DBI:mysql:gswikidb:wesson.cs.waikato.ac.nz';
 
 $username='root';
 (I used //root// without a password to log in. You may need to set $password if authentication is required.)
  
 $sql_query = 'SELECT * FROM gw_user';
  
 %db_to_greenstone_fields=(
 "user_name" => "Title",
 "user_real_name" => "text",
 "user_id" => "Identifier",
 ); 
 (This is a mapping between field names in gw_user, and metadata names in the <br/> Greenstone archive files.)
  • Then I built the collection.

Notes about Perl modules.

  • download following modules from CPAN
    • DBI
    • Data::ShowTable
    • DBD::mysql
  • install these modules: make sure you have run 'setup.bat' or 'source setup.bash' in your greenstone directory first)
  • put them in $GSDLHOME/packages/cpan.
  • untarred them (tar xzvf file.tar.gz)
  • for DBI and Data:ShowTable, run
 perl Makefile.PL INSTALLSITELIB="$GSDLHOME/perllib/cpan/perl-5.8"  PREFIX="$GSDLHOME/perllib/cpan/XXX" SITEPREFIX="$GSDLHOME/perllib/cpan" 
 make 
 make test
 make install

*for DBD:mysql, run

 perl Makefile.PL --testdb=gswikidb --testhost=wesson.cs.waikato.ac.nz --testuser=root <br/> INSTALLSITELIB="$GSDLHOME/perllib/cpan/perl-5.8" <br/>  PREFIX="$GSDLHOME/perllib/cpan/XXX" SITEPREFIX="$GSDLHOME/perllib/cpan" 
 make 
 make test
 make install

This installs the modules into $GSDLHOME/perllib/cpan/perl-5.8

(XXX in the perl line should be set to the first component of the module name, e.g. DBI,DBD,Data)

old/mysql_processing_using_dbplug.txt · Last modified: 2023/03/13 01:46 by 127.0.0.1