NAME
FileMetadata::Store::DBI
DESCRIPTION
This modules implements a store for the FileMetadata framework using a Perl DBI supported database. Such a database should be available and a table must be designed to hold the required data. This module does not implement any methods to retrieve the information from the database - except for the has() method.
METHODS
new
The new method validates the config hash passed to it. It also connects to the database and prepares a statement used for inserting values into the database by store when all columns are available. This method will call 'die' if any errors occur with the config hash or while performing database operations.
The format for the config hash is as follows
{
database =
>
;
'DBI:mysql:test'
,
username =
>
;
'user'
,
password =
>
;
'pass'
,
table =
>
;
'table'
,
column =
>
; [{name =
>
;
'id_column'
,
property =
>
;
'ID'
,
type =
>
;
'SQL_STRING'
},
{name =
>
;
'timestamp_column'
,
property =
>
;
'TIMESTAMP'
,
type =
>
;
'SQL_INTEGER'
},
{name =
>
;
'FileMetadata::Miner::HTML::author'
,
default
=
>
;
'Jules Verne'
}]
}
database, username and password are used to make a connection to the SQL database. See "connect" in DBI for the correct format for these keys. The column key defines association of column names to property names. The name key and the property key are required. Optionally the SQL type of the value can be specified using 'type'. See DBI for more information on possible values. The 'default' key specifies values to be used if no information is available for the corresponding attribute.
This XML is parsed into the above hash by XML::Simple::XMLin($xml, keyattr => [])
store
See "store" in FileMetadata::Store
The store performs an INSERT into the database. Only properties specified in the config hash passed to the new() method are inserted.
remove
See "remove" in FileMetadata::Store
The store performs a DELETE on the database.
clear
See "clear" in FileMetadata::Store
The store performs a DELETE on the database.
has
See "has" in FileMetadata::Store
The has method queries the database for the row containing a 'ID' or equivalent column value of the requested identifier. The column name for the 'ID' property is identified from the config has passed to the constructor. The insertion time of this row is identified from the timestamp column specified in the config hash passed to the new() method.
list
See "has" in FileMetadata::Store
The list method queries the database for the 'ID' or equivalent column of all rows and returns an aray reference to a list of these values. The column name for the 'ID' property is identified from the config has passed to the new () method.
finish
This method releases the prepared statement and disconnects from the database.
VERSION
0.1 - This is the first release
REQUIRES
DBI
AUTHOR
Midh Mulpuri midh@enjine.com
LICENSE
This software can be used under the terms of any Open Source Initiative approved license. A list of these licenses are available at the OSI site - http://www.opensource.org/licenses/