Hi, all
I am trying to write Perl script using DBI module to manupulate the database
on our virtual server.
I wrote the following code:
#! /usr/bin/perl5
use DBI;
$dbHandle = DBI->connect("DBI:Pg:dbname=best",'','') or $DBI::errstr;
$sql ="SELECT * FROM sample";
$statementHandle = $dbHandle->prepare($sql);
$statementHandle->excute() || die $statementHandle->errstr;
$arrayRef = $statementHandle->fetchall_arrayref;
$dbHandle->disconnect();
print $arrayRef ;
after compiling, I got the following error message:
connectDB() failed: Is the postmaster running and accepting connections at 'UNIX
Socket' on port '5432'?
at sample.pl line 4
but when I run
% psql
in the shell, everything works just OK.
Why my script cannot connect to the database? What I need to do for this?
Thanks a lot.
James