source: tags/gsdl-2_70u-distribution/gsdl/etc/packages/example.dbi@ 11745

Last change on this file since 11745 was 10924, checked in by jrm21, 19 years ago

updated for sql_query_prime and more hints re CSV files.

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