en:user_advanced:using_databaseplugin
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | en:user_advanced:using_databaseplugin [2023/03/13 01:46] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
+ | |||
+ | |||
+ | ======Using Database Plugin====== | ||
+ | |||
+ | [[en: | ||
+ | DBI includes back-ends for mysql, postgresql, comma separated values (CSV), MS Excel, ODBC, sybase, etc. You will need to have the DBI module installed, as well as the appropriate back end module(s). | ||
+ | |||
+ | A dbi configuration file is needed, which specifies how to get records out of a database. | ||
+ | |||
+ | <tabbox Greenstone3> | ||
+ | See ''< | ||
+ | |||
+ | Assuming you have got all the necessary modules installed, then the basic way to use DBPlugin is: | ||
+ | |||
+ | * Add DatabasePlugin to the list of plugins for your collection. | ||
+ | * Copy ''< | ||
+ | * Modify this file appropriately | ||
+ | * You may want to have more than one copy of the file, for different database connections/ | ||
+ | * Import and build the collection. | ||
+ | <tabbox Greenstone2> | ||
+ | See ''< | ||
+ | |||
+ | Assuming you have got all the necessary modules installed, then the basic way to use DBPlugin is: | ||
+ | |||
+ | * Add DatabasePlugin to the list of plugins for your collection. | ||
+ | * Copy ''< | ||
+ | * Modify this file appropriately | ||
+ | * You may want to have more than one copy of the file, for different database connections/ | ||
+ | * Import and build the collection. | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ===== Access Processing ===== | ||
+ | |||
+ | This describes my experience of getting DatabasePlugin to get records out of MS Access database. | ||
+ | |||
+ | * My test collection is called //testacc// installed in // | ||
+ | * My access database file was called TestAccess.mdb and was put in my collection' | ||
+ | * My test access table is called // | ||
+ | * I copied // | ||
+ | * This file was modified by setting the following variables: | ||
+ | < | ||
+ | | ||
+ | </ | ||
+ | < | ||
+ | | ||
+ | </ | ||
+ | < | ||
+ | | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ); | ||
+ | </ | ||
+ | |||
+ | This is a mapping between column names in the // | ||
+ | |||
+ | * Then I built the collection. | ||
+ | |||
+ | **Notes about Perl modules.** | ||
+ | |||
+ | * download following modules from [[http:// | ||
+ | * DBI | ||
+ | * DBD::ADO | ||
+ | * Win32::OLE | ||
+ | //Note//:I couldn' | ||
+ | * install these modules: make sure you have run ' | ||
+ | * put them in %GSDLHOME%/ | ||
+ | * unpack them | ||
+ | * setup the C/C++ compiler for Windows. I used VC++. | ||
+ | * run | ||
+ | < | ||
+ | perl Makefile.PL INSTALLSITELIB=" | ||
+ | | ||
+ | nmake test | ||
+ | nmake install | ||
+ | </ | ||
+ | |||
+ | This installs the modules into %GSDLHOME%/ | ||
+ | |||
+ | //Note:// I added | ||
+ | < | ||
+ | | ||
+ | </ | ||
+ | |||
+ | in the //BEGIN// block of // | ||
+ | |||
+ | |||
+ | I also added that line in the //BEGIN// block of // | ||
+ | |||
+ | ===== MySQL Processing ===== | ||
+ | This describes my experience of getting DBPlug to get records for a mysql database. | ||
+ | * My test mysql is installed on // | ||
+ | * My greenstone is installed in /// | ||
+ | * My test database is called // | ||
+ | * My test database table is // | ||
+ | |||
+ | * I copied // / | ||
+ | * This file was modified by setting the following variables: | ||
+ | < | ||
+ | | ||
+ | |||
+ | | ||
+ | (I used //root// without a password to log in. You may need to set $password if authentication is required.) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | | ||
+ | (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 [[http:// | ||
+ | * DBI | ||
+ | * Data:: | ||
+ | * DBD::mysql | ||
+ | * install these modules: make sure you have run ' | ||
+ | * put them in $GSDLHOME/ | ||
+ | * untarred them (tar xzvf file.tar.gz) | ||
+ | * for DBI and Data: | ||
+ | < | ||
+ | perl Makefile.PL INSTALLSITELIB=" | ||
+ | | ||
+ | make test | ||
+ | make install | ||
+ | </ | ||
+ | *for DBD:mysql, run | ||
+ | < | ||
+ | perl Makefile.PL --testdb=gswikidb --testhost=wesson.cs.waikato.ac.nz --testuser=root <br/> INSTALLSITELIB=" | ||
+ | | ||
+ | make test | ||
+ | make install | ||
+ | </ | ||
+ | |||
+ | |||
+ | This installs the modules into $GSDLHOME/ | ||
+ | |||
+ | |||
+ | (XXX in the perl line should be set to the first component of the module name, e.g. DBI, | ||
+ | |||
+ | ===== CSV Processing ===== | ||
+ | |||
+ | This describes my experience of getting DBPlug to process CSV (comma separated value) files using DBPlug. | ||
+ | |||
+ | * My test collection is called csvtest, and my greenstone is installed in / | ||
+ | * My csv file was called demo.txt, and I put it in my collection' | ||
+ | * I copied / | ||
+ | * This file was modified by setting the following variables: | ||
+ | < | ||
+ | | ||
+ | </ | ||
+ | f_dir is the directory containing the csv file. If you want to use ; as a separator, then you need to escape it, e.g. csv_sep_char=\; | ||
+ | < | ||
+ | | ||
+ | </ | ||
+ | < | ||
+ | %db_to_greenstone_fields=( | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ); | ||
+ | </ | ||
+ | |||
+ | This is a mapping between field names in the CSV file, and metadata names in the Greenstone archive files. | ||
+ | |||
+ | * The csv file should consist of one line containing the field names (no . allowed, so don't put namespaces here). Then each line after that is a new record, with the values for each field. The separator char used between fields needs to be specified in the $db line in the dbi file. Don't have blank lines as they end up as new (useless) records too. | ||
+ | |||
+ | * My csv file looked like this: | ||
+ | < | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | * Then I built the collection. | ||
+ | |||
+ | **Notes about Perl modules.** | ||
+ | |||
+ | My Linux distribution had the DBI module installed, but other needed modules were missing. I discovered which ones were needed by running the import: If a module is missing, you get an error like: | ||
+ | < | ||
+ | | ||
+ | / | ||
+ | | ||
+ | | ||
+ | | ||
+ | at / | ||
+ | </ | ||
+ | this message tells us that DBI/ | ||
+ | I had to download and install the following modules: | ||
+ | * DBD::CSV | ||
+ | * DBD::File | ||
+ | * DBI:: | ||
+ | * SQL:: | ||
+ | * Text:: | ||
+ | To install these, I downloaded each from [[http:// | ||
+ | (make sure you have run ' | ||
+ | < | ||
+ | perl Makefile.PL INSTALLSITELIB=" | ||
+ | make | ||
+ | make test | ||
+ | make install | ||
+ | </ | ||
+ | (XXX in the perl line should be set to the first component of the module name, e.g. DBD, DBI, SQL etc) | ||
+ | |||
+ | This installs the modules into $GSDLHOME/ | ||
+ | |||
+ | |||
+ | |||
+ | ===== Excel Processing ===== | ||
+ | This describes my experience of getting DatabasePlugin to process MS excel files. | ||
+ | |||
+ | * My test collection is called testexce installed in / | ||
+ | * My excel file was called phonebook.xls and was put in my collection' | ||
+ | * I copied / | ||
+ | * This file was modified by setting the following variables: | ||
+ | < | ||
+ | | ||
+ | </ | ||
+ | < | ||
+ | | ||
+ | </ | ||
+ | |||
+ | **Important**: | ||
+ | < | ||
+ | %db_to_greenstone_fields=( | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ); | ||
+ | </ | ||
+ | |||
+ | |||
+ | This is a mapping between column names in the //Sheet1// worksheet, and metadata names in the Greenstone archive files. | ||
+ | * Then I built the collection. | ||
+ | **Notes about Perl modules.** | ||
+ | * download following modules from [[http:// | ||
+ | * DBI | ||
+ | * DBD::Excel | ||
+ | * Spreadsheet:: | ||
+ | * Spreadsheet:: | ||
+ | * SQL:: | ||
+ | * OLE:: | ||
+ | * install these modules: make sure you have run ' | ||
+ | * put them in $GSDLHOME/ | ||
+ | * untarred them (tar xzvf file.tar.gz) | ||
+ | * run | ||
+ | < | ||
+ | perl Makefile.PL INSTALLSITELIB=" | ||
+ | | ||
+ | make test | ||
+ | make install | ||
+ | </ | ||
+ | This installs the modules into $GSDLHOME/ | ||
+ | |||
+ | (XXX in the perl line should be set to the first component of the module name, e.g. DBI, | ||
+ | |||
+ | // | ||
en/user_advanced/using_databaseplugin.txt · Last modified: 2023/03/13 01:46 by 127.0.0.1