Lines 470-481
sub process_yml_table {
Link Here
|
470 |
my $placeholders = '(' . join ( ",", map { "?" } @columns ) . ')'; # '(?,..,?)' string |
470 |
my $placeholders = '(' . join ( ",", map { "?" } @columns ) . ')'; # '(?,..,?)' string |
471 |
my @values; |
471 |
my @values; |
472 |
foreach my $row ( @rows ) { |
472 |
foreach my $row ( @rows ) { |
473 |
push @values, map { |
473 |
push @values, [ map { |
474 |
my $col = $_; |
474 |
my $col = $_; |
475 |
( @multiline and grep { $_ eq $col } @multiline ) |
475 |
( @multiline and grep { $_ eq $col } @multiline ) |
476 |
? join "\r\n", @{$row->{$col}} # join multiline values |
476 |
? join "\r\n", @{$row->{$col}} # join multiline values |
477 |
: $row->{$col}; |
477 |
: $row->{$col}; |
478 |
} @columns; |
478 |
} @columns ]; |
479 |
} |
479 |
} |
480 |
return { query => $query, placeholders => $placeholders, values => \@values }; |
480 |
return { query => $query, placeholders => $placeholders, values => \@values }; |
481 |
} |
481 |
} |
Lines 509-516
sub load_sql {
Link Here
|
509 |
my $placeholders = $query_info->{placeholders}; |
509 |
my $placeholders = $query_info->{placeholders}; |
510 |
my $values = $query_info->{values}; |
510 |
my $values = $query_info->{values}; |
511 |
# Doing only 1 INSERT query for the whole table |
511 |
# Doing only 1 INSERT query for the whole table |
512 |
$query .= join ', ', ( $placeholders ) x scalar @values; |
512 |
my @all_rows_values = map { @$_ } @$values; |
513 |
$dbh->do( $query, undef, @values ); |
513 |
$query .= join ', ', ( $placeholders ) x scalar @$values; |
|
|
514 |
$dbh->do( $query, undef, @all_rows_values ); |
514 |
} |
515 |
} |
515 |
for my $statement ( @{ $yaml->{'sql_statements'} } ) { # extra SQL statements |
516 |
for my $statement ( @{ $yaml->{'sql_statements'} } ) { # extra SQL statements |
516 |
$dbh->do($statement); |
517 |
$dbh->do($statement); |
517 |
- |
|
|