App-MBUtiny
view release on metacpan or search on metacpan
lib/App/MBUtiny/Collector/DBI.pm view on Meta::CPAN
package App::MBUtiny::Collector::DBI; # $Id: DBI.pm 128 2019-07-06 15:27:48Z abalama $
use strict;
use utf8;
=encoding utf8
=head1 NAME
App::MBUtiny::Collector::DBI - Collector database interface
=head1 VERSION
Version 1.02
=head1 SYNOPSIS
use App::MBUtiny::Collector::DBI;
my $dbi = new App::MBUtiny::Collector::DBI(
dsn => "DBI:mysql:database=mbutiny;host=mysql.example.com",
user => "username",
password => "password",
set => [
"RaiseError 0",
"PrintError 0",
"mysql_enable_utf8 1",
],
);
print STDERR $dbi->error if $dbi->error;
=head1 DESCRIPTION
Collector database interface
=head2 new
my $dbi = new App::MBUtiny::Collector::DBI(
dsn => "DBI:mysql:database=mbutiny;host=mysql.example.com",
user => "username",
password => "password",
set => [
"RaiseError 0",
"PrintError 0",
"mysql_enable_utf8 1",
],
);
Creates DBI object
=head2 add
$dbi->add(
type => 0,
name => "foo",
addr => "127.0.0.1",
status => 0,
file => "foo-2019-06-25.tar.gz",
size => 123456,
md5 => "...",
sha1 => "...",
error => "...",
comment => "...",
) or die $dbi->error;
Add new record on collector database
=head2 del
$dbi->del(
type => 0,
name => "foo",
addr => "127.0.0.1",
file => "foo-2019-06-25.tar.gz",
) or die $dbi->error;
Delete record from collector database
=head2 dsn
my $dsn = $dbi->dsn;
Returns DSN string of current collector database connection
=head2 error
my $error = $dbi->error;
$dbi->error("Error message");
Gets/sets error string
=head2 get
my %info = $dbi->get(
name => "foo",
file => "foo-2019-06-25.tar.gz",
);
Gets information about file from collector database
Format:
{
id => 1,
type => 0,
( run in 0.877 second using v1.01-cache-2.11-cpan-39bf76dae61 )