source: main/tags/2.61/gsdl/etc/packages/example.dbi

Last change on this file was 8119, checked in by jrm21, 20 years ago

allow multiple callbacks, one for each metadata field (using the
metadata name that greenstone sees, rather than the column name in the DB).

Updated the example file to show how to do this.

  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
1# -*- perl -*-
2# This is an example configuration file for greenstone's DBPlug
3# (DataBase plugin).
4#
5# This config file should be a fragment of perl, specifying how to
6# get records out of a database. This uses perl's DBI module, which
7# includes back-ends for mysql, postgresql, comma separated values (CSV),
8# MS Excel, ODBC, sybase, etc...
9#
10# You need to install the separate backends - For example, on debian you
11# need the libdbi-perl base package and then the libdbd-mysql-perl,
12# libdbd-csv-perl, libdbd-pg-perl and/or libdbd-sybase-perl (etc) packages.
13
14
15# debugging. Uncomment this line if you want extra information printed
16# out during greenstone's import process.
17#
18$dbplug_debug=1;
19
20
21# If these are commented out, then we will use the plugin's defaults.
22# However, you might want to override them here if you know what they
23# are for this particular database
24# run "$ pluginfo.pl DBPlug | less" to see a list of valid encodings
25# Language metadata isn't really necessary unless you want indexes by language
26# However, Encoding is important, for converting data to utf8
27#
28$language = "en";
29$encoding = "iso_8859_1";
30
31
32# Data Source.
33# This is going to be dependent on which back-end you use.
34# Eg, for postgres, it is "DBI:Pg:dbname=<database>".
35# For mysql, it might look like "DBI:mysql:database=<database>;host=localhost"
36# Case is important!
37#
38#$db='';
39
40# If you need a username and password to connect to this database,
41# uncomment these lines and fill in the details
42#
43#$username='';
44#$password='';
45
46# sql query required to get your rows out of the database. Each row will
47# become a separate greenstone document.
48#
49#$sql_query = 'SELECT id, name, data FROM table1 JOIN table2 WHERE something';
50
51
52# a map of database field names to Greenstone metadata field names.
53# You should have a "Title" field and a "text" field, at a minimum.
54# If you want to give records a unique identifier from a database field
55# rather than have greenstone perform a hash on the document, also provide
56# an "Identifier" metadata field.
57# If you do map something to Identifier, make sure that the field is unique
58# for each record, and also note that because greenstone does special things
59# if this field is only numeric, DBPlug will add some letters to the front
60# if this is the case.
61#
62#%db_to_greenstone_fields=(
63# "name" => "Title",
64# "data" => "text",
65# "id" => "Identifier"
66# );
67
68
69# finally, you can declare subroutines here to post-process the fields
70# in case you want to do any mark up or processing of it.
71# For example, you might want to do HTML formatting.
72# The subroutine's name should be the greenstone metadata field name,
73# followed by "_callback", and must end with "}" in the first column.
74#
75#sub text_callback {
76# my $text=shift;
77# # do markup stuff...
78# return $text;
79#}
80#
81#sub Title_callback {
82# my $title=shift;
83# return ucfirst($title); # uppercase first letter
84#}
85
Note: See TracBrowser for help on using the repository browser.