November 24, 2024, 08:03:24 PM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: PERL & POSTGRES SWITCH THROUGH DBI  (Read 6530 times)

Offline sani

  • New Member
  • Posts: 1
PERL & POSTGRES SWITCH THROUGH DBI
« on: April 17, 2004, 08:41:16 AM »
I have problems with my script in perl. I just tried to open a table in a postgres server through this perl script.


#-------------------------------SCRIPT--------------------------------

#!/usr/bin/perl5

use DBI;
print "Successful\n";

$dbh=DBI->connect("db:Pg:dbname=/var/lib/pgsql/data/base/test1:localhost","postg
res","postgres") || die "Error : $DBI::errstr";
print "working....\n";

$dbh->disconnect;
print "connection successful\n";
----------------------------------------------------------------------------
But it not connecting.
----------------------------------------------------------------------------
The Error was
---------------------------------------
Successful
Can't connect(db:Pg:dbname=/var/lib/pgsql/data/base/test1:localhost postgres pos
tgres), no database driver specified and DBI_DSN env var not set at test.pl line
 7

-----------------------------------------------------------------------------

what is thr problem now? why i can't connect. pls help me.

I installed DBD & DBI successfully and set Environment varible in .bash_profile.

So it was fine.  But at last not.



Kindly give me guidance. I am a beginner in this perl and postgres.

regards

sani :)