line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/env perl |
2
|
|
|
|
|
|
|
package ysql; |
3
|
|
|
|
|
|
|
our $VERSION = '0.035'; |
4
|
|
|
|
|
|
|
# ABSTRACT: Query SQL databases in a Yertl workflow |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
442
|
use ETL::Yertl; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
7
|
1
|
|
|
1
|
|
268
|
use Pod::Usage::Return qw( pod2usage ); |
|
1
|
|
|
|
|
40417
|
|
|
1
|
|
|
|
|
64
|
|
8
|
1
|
|
|
1
|
|
527
|
use Getopt::Long qw( GetOptionsFromArray :config pass_through ); |
|
1
|
|
|
|
|
8433
|
|
|
1
|
|
|
|
|
4
|
|
9
|
1
|
|
|
1
|
|
625
|
use ETL::Yertl::Command::ysql; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
226
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$|++; # no buffering |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub main { |
14
|
39
|
|
|
39
|
|
508367
|
my ( $class, @argv ) = @_; |
15
|
39
|
|
|
|
|
94
|
my %opt; |
16
|
39
|
|
|
|
|
284
|
GetOptionsFromArray( \@argv, \%opt, |
17
|
|
|
|
|
|
|
'help|h', |
18
|
|
|
|
|
|
|
'version', |
19
|
|
|
|
|
|
|
'dsn=s', |
20
|
|
|
|
|
|
|
); |
21
|
39
|
50
|
|
|
|
17912
|
return pod2usage(0) if $opt{help}; |
22
|
39
|
50
|
|
|
|
131
|
if ( $opt{version} ) { |
23
|
0
|
|
|
|
|
0
|
print "ysql version $ysql::VERSION (Perl $^V)\n"; |
24
|
0
|
|
|
|
|
0
|
return 0; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
39
|
|
|
|
|
120
|
eval { |
28
|
39
|
|
|
|
|
408
|
ETL::Yertl::Command::ysql->main( @argv, \%opt ); |
29
|
|
|
|
|
|
|
}; |
30
|
39
|
100
|
|
|
|
1560
|
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
|
|
|
42
|
if ( $@ =~ /^SQL error/ || $@ =~ /^Could not connect/ ) { |
34
|
4
|
|
|
|
|
121
|
print STDERR "ERROR: $@"; |
35
|
4
|
|
|
|
|
27
|
return 1; |
36
|
|
|
|
|
|
|
} |
37
|
3
|
|
|
|
|
20
|
return pod2usage( "ERROR: $@" ); |
38
|
|
|
|
|
|
|
} |
39
|
32
|
|
|
|
|
197
|
return 0; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
exit __PACKAGE__->main( @ARGV ) unless caller(0); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |