DBI connection problem - Mailing list pgsql-general

From Ji Li
Subject DBI connection problem
Date
Msg-id 000701bea863$99c27800$a49577d8@netiger.faxtel.com
Whole thread Raw
List pgsql-general
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

pgsql-general by date:

Previous
From: carlino
Date:
Subject: Couldn't find any tables!
Next
From: Piotr Stelmaszyk
Date:
Subject: geometric functions