line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Amazon::MechanicalTurk::RowData::SQLRowData; |
2
|
1
|
|
|
1
|
|
593
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
4
|
1
|
|
|
1
|
|
6
|
use Net::Amazon::MechanicalTurk::RowData; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
4
|
use IO::File; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
153
|
|
6
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
54
|
|
7
|
1
|
|
|
1
|
|
1555
|
use DBI; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw{ Net::Amazon::MechanicalTurk::RowData }; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Net::Amazon::MechanicalTurk::RowData::SQLRowData->attributes(qw{ |
14
|
|
|
|
|
|
|
dbh |
15
|
|
|
|
|
|
|
sql |
16
|
|
|
|
|
|
|
params |
17
|
|
|
|
|
|
|
}); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init { |
20
|
|
|
|
|
|
|
my $self = shift; |
21
|
|
|
|
|
|
|
$self->setAttributes(@_); |
22
|
|
|
|
|
|
|
$self->assertRequiredAttributes(qw{ dbh sql }); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub each { |
26
|
|
|
|
|
|
|
my ($self, $block, @blockXArgs) = @_; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $sql = $self->sql; |
29
|
|
|
|
|
|
|
my $sth = $self->dbh->prepare($sql); |
30
|
|
|
|
|
|
|
if (!$sth) { |
31
|
|
|
|
|
|
|
Carp::croak("Couldn't prepare sql '$sql' - " . $self->dbh->errstr . "."); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
$sth->{RaiseError} = 1; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
eval { |
36
|
|
|
|
|
|
|
my @params; |
37
|
|
|
|
|
|
|
@params = @{$self->params} if $self->params; |
38
|
|
|
|
|
|
|
$sth->execute(@params); |
39
|
|
|
|
|
|
|
my $rowNumber = 0; |
40
|
|
|
|
|
|
|
while (my $row = $sth->fetchrow_hashref) { |
41
|
|
|
|
|
|
|
if ($rowNumber++ == 0) { |
42
|
|
|
|
|
|
|
# Make a copy of the fieldNames |
43
|
|
|
|
|
|
|
$self->fieldNames([@{$sth->{NAME}}]); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
$block->($self, $row, @blockXArgs); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
if ($@) { |
49
|
|
|
|
|
|
|
# clean up the handle |
50
|
|
|
|
|
|
|
$sth->finish; |
51
|
|
|
|
|
|
|
die $@; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
$sth->finish; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
return 1; |