NAME

Module::CPANTS::Reporter::DB - save metrics in a database

SYNOPSIS

see Module::CPANTS::Reporter

DESCRIPTION

Module::CPANTS::Reporter::DB saves metrics into a database. Any database system can be used, as long as there is an DBI driver available.

You must specify the connection information in the CPANTS config file (.cpants) as an array ref.

# in .cpants
dbi_connect=>["dbi:mysql:cpants",'','',{RaiseError=>1}],

This array ref will be passed directly to DBI's connect.

Methods

init

Connects to DB. The DBH is stored in a package global.

DBH

Returns the package-globally stored DBH.

report

Saves metrics into the DB.

As the metrics come as one big hash, the following logic is used to split the date into different tables:

  • If the value is a string, it will be stored in table 'cpants' using the key as the column name.

  • If the value is a hashref, the key denotes the name of the table to store the data. The keys and values of the hashref are used as columns and data.

  • If the value is an arrayref, iterate over the values of the array, which must be hashrefs. The name of the key is again the name of the table. For each array value (which is a hashref), the keys and values of this hash are used as columns and data.

Prior to saving the metrics, all data for the current distribution is deleted.

finish

Not used.

get_tables

Returns a list of tables by doing an analysis of the metrics data somewhat similar to report, only simpler. This list is used to delete old data.

AUTHOR

Thomas Klausner <domm@zsi.at>

http://domm.zsi.at

LICENSE

This code is distributed under the same license as Perl.