65 |
my $sql = ""; |
my $sql = ""; |
66 |
while(<SQL>) { |
while(<SQL>) { |
67 |
chomp; |
chomp; |
68 |
if (/^--(.+)/) { |
if (/^\\c\s+(\S+)/) { |
69 |
|
warn "## connect to $1\n" if $debug; |
70 |
|
$dbh = DBI->connect('DBI:Pg:dbname=' . $1,$user,$passwd) || die $DBI::errstr; |
71 |
|
} elsif (/^--(.+)/) { |
72 |
$comment.=$1; |
$comment.=$1; |
73 |
} else { |
} else { |
74 |
$sql.=$_; |
$sql.= ' ' . $_; |
75 |
} |
} |
76 |
} |
} |
77 |
close(SQL); |
close(SQL); |
78 |
|
|
79 |
|
$sql =~ s/\s\s+/ /gs; |
80 |
|
|
81 |
print STDERR "sql: $sql\ncomment: $comment\n" if ($debug); |
print STDERR "sql: $sql\ncomment: $comment\n" if ($debug); |
82 |
|
|
83 |
my $row = 0; |
my $row = 0; |
110 |
my $data = $row[$col]; |
my $data = $row[$col]; |
111 |
if ( $types[$col] =~ m/^date/i ) { |
if ( $types[$col] =~ m/^date/i ) { |
112 |
$data .= 'T' if $data =~ m/^\d\d\d\d-\d\d-\d\d$/; |
$data .= 'T' if $data =~ m/^\d\d\d\d-\d\d-\d\d$/; |
113 |
|
$data =~ s/^(\d\d\d\d-\d\d-\d\d)\s(\d\d:\S+)$/$1T$2/; |
114 |
|
warn "## $data\n"; |
115 |
$worksheet->write_date_time( $row, $col, $data, $date_format ); |
$worksheet->write_date_time( $row, $col, $data, $date_format ); |
116 |
} else { |
} else { |
117 |
$worksheet->write($row, $col, _c( $data ) ); |
$worksheet->write($row, $col, _c( $data ) ); |