/usr/share/doc/libdbix-xml-rdb-perl/examples/sql2xml.pl is in libdbix-xml-rdb-perl 0.05-12.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | #!/usr/bin/perl -w
require 5.004;
use strict;
use DBIx::XML_RDB;
use Getopt::Long;
use vars qw($datasource $driver $userid $password $table $outputfile $help $dbname $verbose @fields);
sub usage;
# Options to variables mapping
my %optctl = (
'sn' => \$datasource,
'uid' => \$userid,
'pwd' => \$password,
'table' => \$table,
'output' => \$outputfile,
'help' => \$help,
'db' => \$dbname,
'driver' => \$driver,
'verbose' => \$verbose );
# Option types
my @options = (
"sn=s",
"uid=s",
"pwd=s",
"table=s",
"output=s",
"db=s",
"driver=s",
"help",
"verbose"
);
GetOptions(\%optctl, @options) || die "Get Options Failed";
usage if $help;
unless ($datasource && $userid && $table && $outputfile) {
usage;
}
$driver = $driver || "ODBC"; # ODBC is the default. Change this if you wish.
my $xmlout = DBIx::XML_RDB->new($datasource, $driver, $userid, $password, $dbname)
|| die "Failed to make new xmlout";
$xmlout->DoSql("SELECT * FROM $table ORDER BY 1");
use IO::File;
my $output = IO::File->new(">". $outputfile);
print $output $xmlout->GetData;
# End
sub usage {
print <<EOF;
Usage:
sql2xls.pl {Options}
where options are:
Option ParamName ParamDesc
-sn servername Data source name
[-driver dbi_driver] Driver that DBI uses. Default is ODBC
-uid username Username
[-pwd password] Password
-table tablename Table to extract
-output outputfile File to place output in (excel file)
[-db dbname] Sybase database name
[-v or --verbose] Verbose output
EOF
exit;
}
|