83 |
# Add a worksheet |
# Add a worksheet |
84 |
my $worksheet = $workbook->addworksheet($sheet_name); |
my $worksheet = $workbook->addworksheet($sheet_name); |
85 |
|
|
86 |
print STDERR "working on $sql_file...\n" if ($debug); |
print STDERR "working on $sql_file\n" if ($debug); |
87 |
|
|
88 |
open(SQL,$sql_file) || die "can't open sql file '$sql_file': $!"; |
open(SQL,$sql_file) || die "can't open sql file '$sql_file': $!"; |
89 |
my $comment; |
my $comment; |
91 |
while(<SQL>) { |
while(<SQL>) { |
92 |
chomp; |
chomp; |
93 |
if (/^\\c\s+(\S+)/) { |
if (/^\\c\s+(\S+)/) { |
94 |
warn "## connect to $1\n" if $debug; |
$dbh->disconnect if $dbh; |
95 |
|
print STDERR "## connect to $1\n" if $debug; |
96 |
$dbh = DBI->connect($dsn . $1,$user,$passwd, { RaiseError => 1, AutoCommit => 0 }) || die $DBI::errstr; |
$dbh = DBI->connect($dsn . $1,$user,$passwd, { RaiseError => 1, AutoCommit => 0 }) || die $DBI::errstr; |
97 |
} elsif (/^--(.+)/) { |
} elsif (/^--(.+)/) { |
98 |
$comment.=$1; |
$comment.=$1; |
129 |
} |
} |
130 |
$row++; |
$row++; |
131 |
|
|
132 |
my @types = map { scalar $dbh->type_info($_)->{TYPE_NAME} } @{ $sth->{TYPE} }; |
my @types = map { $dbh->type_info($_) ? $dbh->type_info($_)->{TYPE_NAME} : '?' } @{ $sth->{TYPE} }; |
133 |
|
|
134 |
while (my @row = $sth->fetchrow_array() ) { |
while (my @row = $sth->fetchrow_array() ) { |
135 |
for(my $col=0; $col<=$#row; $col++) { |
for(my $col=0; $col<=$#row; $col++) { |