blib/lib/PMLTQ/Command/verify.pm

filter: Statementstmt 28.0% 7 / 25 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 1 / 3 Podpod 0.0% 0 / 1 totaltotal 25.8% 8 / 31 CC 3 SCAR 20.3
CC
3
Cov
26%
run
12.0
__ANON__
1.1
BEGIN
1.0
CRAP 7.6
« blib/lib/PMLTQ/Relation/PDT/TEParentIterator.pm ↑ Summary blib/lib/PMLTQ/Relation/AncestorIterator.pm »
1 package PMLTQ::Command::verify;
2 1 our $AUTHORITY = 'cpan:MATY';
3 1 $PMLTQ::Command::verify::VERSION = '1.2.2';
4 # ABSTRACT: Check if database exists and that it contains some data
5  
6 1 ▶use PMLTQ::Base 'PMLTQ::Command';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶has usage => sub { shift->extract_usage };
Subroutine __ANON__: not called CC=1 SCAR=1.2
9  
10 sub run {
11 0 ▶ my $self = shift;
Subroutine run: not called CC=3 SCAR=24.8
Pod undocumented
12  
13 0 my $db_name = $self->config->{db}->{name};
14  
15 0 my $dbh;
16 0 eval { $dbh = $self->db };
17  
18 0 ▶ die "Database " . $db_name . " does not exist!\n" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
19 0 print "Database " . $db_name . " exists\n";
20  
21 0 my @tables = map { s/^public\.//; $_ } grep {m/^public\./} $dbh->tables();
22 0 print "Database contains ", scalar @tables, " tables\n";
23 0 for my $table (@tables) {
24 0 my $sth = $dbh->prepare("SELECT * FROM $table");
25 0 $sth->execute;
26 0 print "Table $table contains " . $sth->rows . " rows\n";
27 }
28 0 $dbh->disconnect;
29 }
30  
31  
32 1 1;
33  
34 __END__
« blib/lib/PMLTQ/Relation/PDT/TEParentIterator.pm ↑ Summary blib/lib/PMLTQ/Relation/AncestorIterator.pm »