line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/env perl |
2
|
|
|
|
|
|
|
package ysql; |
3
|
|
|
|
|
|
|
our $VERSION = '0.037'; |
4
|
|
|
|
|
|
|
# ABSTRACT: Query SQL databases in a Yertl workflow |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
514
|
use ETL::Yertl; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
7
|
1
|
|
|
1
|
|
287
|
use Pod::Usage::Return qw( pod2usage ); |
|
1
|
|
|
|
|
42869
|
|
|
1
|
|
|
|
|
78
|
|
8
|
1
|
|
|
1
|
|
642
|
use Getopt::Long qw( GetOptionsFromArray :config pass_through ); |
|
1
|
|
|
|
|
7765
|
|
|
1
|
|
|
|
|
4
|
|
9
|
1
|
|
|
1
|
|
626
|
use ETL::Yertl::Command::ysql; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
236
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$|++; # no buffering |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub main { |
14
|
39
|
|
|
39
|
|
483410
|
my ( $class, @argv ) = @_; |
15
|
39
|
|
|
|
|
89
|
my %opt; |
16
|
39
|
|
|
|
|
263
|
GetOptionsFromArray( \@argv, \%opt, |
17
|
|
|
|
|
|
|
'help|h', |
18
|
|
|
|
|
|
|
'version', |
19
|
|
|
|
|
|
|
'dsn=s', |
20
|
|
|
|
|
|
|
); |
21
|
39
|
50
|
|
|
|
17481
|
return pod2usage(0) if $opt{help}; |
22
|
39
|
50
|
|
|
|
152
|
if ( $opt{version} ) { |
23
|
0
|
|
|
|
|
0
|
print "ysql version $ysql::VERSION (Perl $^V)\n"; |
24
|
0
|
|
|
|
|
0
|
return 0; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
39
|
|
|
|
|
74
|
eval { |
28
|
39
|
|
|
|
|
411
|
ETL::Yertl::Command::ysql->main( @argv, \%opt ); |
29
|
|
|
|
|
|
|
}; |
30
|
39
|
100
|
|
|
|
1497
|
if ( $@ ) { |
31
|
|
|
|
|
|
|
# SQL errors do not need usage information |
32
|
|
|
|
|
|
|
# XXX: We need to have some kind of error return message |
33
|
7
|
100
|
100
|
|
|
45
|
if ( $@ =~ /^SQL error/ || $@ =~ /^Could not connect/ ) { |
34
|
4
|
|
|
|
|
99
|
print STDERR "ERROR: $@"; |
35
|
4
|
|
|
|
|
25
|
return 1; |
36
|
|
|
|
|
|
|
} |
37
|
3
|
|
|
|
|
20
|
return pod2usage( "ERROR: $@" ); |
38
|
|
|
|
|
|
|
} |
39
|
32
|
|
|
|
|
196
|
return 0; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
exit __PACKAGE__->main( @ARGV ) unless caller(0); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |