X-Git-Url: http://git.rot13.org/?p=blackray-experiments.git;a=blobdiff_plain;f=sql2blackray.pl;h=9cc5941d3612d2c2e1c98ee5fcdece94152d1a2e;hp=83a100575378274a01472eccfe9cee76198c6a02;hb=HEAD;hpb=0038ec565c3c29022e519f905d766dc53f49811d
diff --git a/sql2blackray.pl b/sql2blackray.pl
index 83a1005..9cc5941 100755
--- a/sql2blackray.pl
+++ b/sql2blackray.pl
@@ -22,11 +22,11 @@ open(my $load, '>', 'load.xml');
sub dump_table {
my $table = shift;
+ my @cols = @_;
+ @cols = ( '*' ) unless @cols;
-my $sql = qq|
- select *
- from $table
-|;
+my $sql = 'select ' . join(',', @cols) . ' from ' . $table;
+warn "# sql $sql\n";
my $sth = $dbh->prepare( $sql );
$sth->execute();
@@ -38,14 +38,14 @@ my @columns = @{ $sth->{NAME} };
warn "columns ", dump @columns;
print $load qq|\n|;
-print $load qq|
| foreach @columns;
-print $load qq||;
+print $load qq|\n|;
my $file = "$table.csv";
-print $load qq||;
+print $load qq|\n|;
foreach my $i ( 0 .. $#columns ) {
print $load qq|
@@ -53,7 +53,7 @@ foreach my $i ( 0 .. $#columns ) {
|;
}
-print $load qq||;
+print $load qq|\n|;
open(my $fh, '>', $file) || die "$file: $!";
@@ -68,8 +68,19 @@ warn "$file ", -s $file, " bytes\n";
}
print $load qq|\n|;
-dump_table 'borrowers';
-dump_table 'borrower_attributes';
+dump_table 'borrowers' => qw(
+ borrowernumber
+ cardnumber
+ surname
+ firstname
+ email
+);
+dump_table 'borrower_attributes' => qw(
+ borrowernumber
+ code
+ attribute
+);
+
print $load qq|\n|;
#$dbh->commit;