SeeAlso::Source::DBI - returns links stored in an SQL database (abstract class)
This class wraps a SQL database that can deliver links for a given identifiers. It is an abstract subclass of SeeAlso::Source and should not used directly. Instead you should define a subclass that implements the following methods:
The query method as required by SeeAlso::Source. The method gets a SeeAlso::Identifier object and returns a SeeAlso::Response object. The method should croak on errors.
Purges and (re)create the database table(s). Usually this is done via a <tt>DROP TABLE IF EXISTS ...</tt> followed by a <tt>CREATE TABLE ...</tt>.
Returns a prepared statement to insert a row into the database. You should either implement this method or set the property insertQuery.
Returns the name of the standard table to load data into. By default returns the propery loadTable.
Create a new SeeAlso server with a given database connection. Subclasses should set the property dbh with DBI connect. It is recommended to support the following options:
First parameter for DBI connect method
Database user
Database Password
A numerical limit for queries
Putting passwords into scripts is not recommended, so you should better use places like pg_service.conf (Postgres) or my.cfg (MySQL).
Return whether a database connection has been established. By default returns the propery dbh.
Returns a prepared statement to insert a row into the database. By default returns the property insertQuery.
Load data from a local file 'file' into the database. By default the prepared statement returned by insertQuery will be used for each line of the file. If the 'bulk' option is set, a much faster bulk import is tried and data is loaded into the table specified by loadTable. Usage example:
$db->loadFile( file => "links.tab", bulk => 1 );
The file must contain tabular seperated data.
Up to now bulk import is only implemented for MySQL.
Parse a string to be inserted into the loadTable with insertQuery. Implementations of this method must return undef (on error) or an array that can directly be passed to insertQuery. By default the method just removes a trailing newline and splits the line by tabulators. Other implementations should also validate the data for not to fill the database with junk.
Purge and (re)create the table table(s). Usually this is done via a <tt>DROP TABLE IF EXISTS ...</tt> followed by a <tt>CREATE TABLE ...</tt>. This method is abstract and will always croak. Any implementation of a subclass should return true on success.
Insert links from a SeeAlso::Response object. Not implemented by default.
Jakob Voss <jakob.voss@gbv.de>
<jakob.voss@gbv.de>
Copyright (C) 2007-2009 by Verbundzentrale Goettingen (VZG) and Jakob Voss
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install SeeAlso::Server, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SeeAlso::Server
CPAN shell
perl -MCPAN -e shell install SeeAlso::Server
For more information on module installation, please visit the detailed CPAN module installation guide.