NAME
App::MBUtiny::Collector::DBI - Collector database interface
VERSION
Version 1.02
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;
DESCRIPTION
Collector database interface
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
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
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
dsn
my $dsn = $dbi->dsn;
Returns DSN string of current collector database connection
error
my $error = $dbi->error;
$dbi->error("Error message");
Gets/sets error string
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,
time => 123456789,
name => "foo"
addr => "127.0.0.1",
status => 1,
file => "foo-2019-06-25.tar.gz",
size => 123456,
md5 => "...",
sha1 => "...",
error => "...",
comment => "...",
}
- addr
-
Client ip addr (IPv4/IPv6)
- comment
-
Comment data
- error
-
Error message
- file
-
Backup filename
- id
-
Record ID. Autoincremented value!
- md5
-
MD5-checksum of backup file
- name
-
Name of mbutiny host
- sha1
-
SHA1-checksum of backup file
- size
-
Size of backup file
- status
-
Backup status: 0=false, 1=true
Default: 0
- time
-
Time of record insert
Default: time()
- type
-
Type of collector: 0=internal, 1=external
Default: 0
is_sqlite
print $dbi->is_sqlite ? "Is SQLite" : "Is not SQLite"
Returns true if type of current collector database is SQLite
list
my @files = $dbi->list(
name => "foo"
);
Returns list of files by specified the name
Record format of return result: see "get"
report
my @files = $dbi->report(
start => 123456789
);
Returns list of all last backup files, starting at the specified the "start" value
Record format of return result: see "get"
SEE ALSO
AUTHOR
Serż Minus (Sergey Lepenkov) http://www.serzik.com <abalama@cpan.org>
COPYRIGHT
Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved
LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See LICENSE
file and https://dev.perl.org/licenses/