source: gsdl/trunk/etc/packages/example.dbi@ 15075

Last change on this file since 15075 was 12686, checked in by kjdon, 18 years ago

small changes to hopefully make it clearer

  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 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. Set to 0 if you don't 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
29$language = "en";
30$encoding = "iso_8859_1";
31
32
33# Data Source.
34# This is going to be dependent on which back-end you use. Note that these
35# strings are case-sensitive.
36# Eg, for postgres, it is "DBI:Pg:dbname=<database>".
37# For mysql, it might look like "DBI:mysql:database=<database>;host=localhost"
38# For the CSV (comma-separated values text-file) backend, try something like
39# 'DBI:CSV:f_dir=/path/to/directory/containing/csvfile;csv_quote_char=\";csv_sep_char= '
40# with an embedded tab character for tab-separated instead of the
41# default comma-separated.
42
43$db='';
44
45# If you need a username and password to connect to this database,
46# uncomment these lines and fill in the details
47#
48#$username='';
49#$password='';
50
51# DBI does not allow you to use multiple SQL statements at once. So if
52# you want to execute two statements (for example, to prep the data by
53# creating a temporary table), uncomment and use this as the first statement.
54
55#$sql_query_prime = 'CREATE TEMP TABLE foo AS
56# SELECT t1.ID, t2.name
57# FROM table1 AS t1 JOIN table2 AS t2
58# ON t1.ID = t2.ID ';
59
60# sql query required to get your rows out of the database. Each row will
61# become a separate greenstone document.
62#
63#$sql_query = 'SELECT id, name, data FROM foo JOIN table2 WHERE something';
64# For CSV, the table name is the file name. Eg:
65#$sql_query = 'SELECT * FROM values.txt'
66# CSV may also require DOS '\r\n'-style line endings instead of unix '\n'.
67# It is easier if your data file does not have a dot '.' in it, as that is
68# not a valid character in an SQL table name (although it works for simple
69# SELECTS but not joins).
70
71$sql_query='';
72
73# a map of database field names to Greenstone metadata field names.
74# You should have a "Title" field and a "text" field, at a minimum.
75# If you want to give records a unique identifier from a database field
76# rather than have greenstone perform a hash on the document, also provide
77# an "Identifier" metadata field.
78# If you do map something to Identifier, make sure that the field is unique
79# for each record, and also note that because greenstone does special things
80# if this field is only numeric, DBPlug will add some letters to the front
81# if this is the case.
82#
83#%db_to_greenstone_fields=(
84# "name" => "Title",
85# "data" => "text",
86# "id" => "Identifier"
87# );
88
89%db_to_greenstone_fields=(
90
91 );
92
93# finally, you can declare subroutines here to post-process the fields
94# in case you want to do any mark up or processing of it.
95# For example, you might want to do HTML formatting.
96# The subroutine's name should be the greenstone metadata field name,
97# followed by "_callback", and must end with "}" in the first column.
98#
99#sub text_callback {
100# my $text=shift;
101# # do markup stuff...
102# return $text;
103#}
104#
105#sub Title_callback {
106# my $title=shift;
107# return ucfirst($title); # uppercase first letter
108#}
109
Note: See TracBrowser for help on using the repository browser.