1 |
dpavlin |
1.1 |
#!/usr/local/bin/perl -w |
2 |
|
|
|
3 |
|
|
use DBI; |
4 |
|
|
|
5 |
|
|
die "SQL query as argument?" if (!defined($ARGV[0])); |
6 |
|
|
|
7 |
|
|
my $connect = "DBI:Pg:dbname=corp"; |
8 |
|
|
#$connect = "DBI:dbftp:DSN=video;hostname=vradan"; |
9 |
|
|
#$connect = "DBI:dbftp:DSN=db1;hostname=hbreyer2"; |
10 |
|
|
#$connect = "DBI:dbftp:DSN=education;user=sa;hostname=mbabic.pliva.hr"; |
11 |
|
|
|
12 |
|
|
my $dbh = DBI->connect("$connect","","") || die $DBI::errstr; |
13 |
|
|
$sth = $dbh->prepare("$ARGV[0]") || die $dbh->errstr(); |
14 |
|
|
$sth->execute() || die $sth->errstr(); |
15 |
|
|
|
16 |
|
|
print "#",join("\t",@{ $sth->{NAME} }),"\n"; |
17 |
|
|
while (@arr = $sth->fetchrow_array() ) { |
18 |
|
|
print join("\t",@arr),"\n"; |
19 |
|
|
} |