ayaniimi213
7/11/2013 - 10:51 PM

PerlSample.pl

#!/usr/bin/perl
use strict;
use DBI;

my $dname = "auction"; # DB:
my $username = "pgsql"; #
my $password = "hoge";

my $debug = 0;

my $db = DBI->connect("DBI:Pg:dbname=$dname",$username,$password);
die "cannot connect $dname" unless defined $db;

my $sthandler = $db->prepare("SELECT * FROM users");
die "cannot connect $dname" unless defined $sthandler;
my $result = $sthandler->execute;
while (my @row = $sthandler->fetchrow_array) {
  print join(" ", @row), "\n";
}
$sthandler->finish();

$db->disconnect;