Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Trouble establishing a dialogue between Perl and PostgreSQL

by DigitalKitty (Parson)
on Jan 14, 2008 at 20:14 UTC ( [id://662370]=perlquestion: print w/replies, xml ) Need Help??

DigitalKitty has asked for the wisdom of the Perl Monks concerning the following question:

Hi all.

I recently upgraded my PostgreSQL install to version 8.2.6 (win32). After doing so, I installed the following modules (DBI was installed previously).


When attempting to connect to a database with DBD::Pg, the connection hung and only by pressing Ctrl-C was I able to terminate the program.

Assuming something might be wrong with the module, I tried DBD::PgPP in a very simple test script (please see below):
#!/usr/bin/perl use warnings; use strict; use DBI; my $db = DBI->connect('dbi:PgPP:testdb', 'postgres', 'xxxxxxxxx'); if( $db ) { print "Connected!\n"; } else { print "Nope. Sorry.\n"; }


After doing so, I immediately noticed the following message:
C:\Perl2\bin>perl test_pg.pl DBI connect('testdb','postgres',...) failed: Couldn't connect to /tmp/ +.s.PGSQL.5432: at C:/Perl2/site/lib/DBD/PgPP.pm line 124 at test_pg.p +l line 5

Is there a configuration setting I need to modify? For testing purposes, I was able to connect to the database with both python and ruby.

Thanks,

~Katie

Replies are listed 'Best First'.
Re: Trouble establishing a dialogue between Perl and PostgreSQL
by erix (Prior) on Jan 14, 2008 at 21:08 UTC

    I wouldn't bother with that old unmaintained DBD::PgPP if not necessary.

    For DBD::Pg, which is very actively maintained, there is a ppm/binary for DBD::Pg here: http://pgfoundry.org/projects/dbdpgppm/

    If you download a local copy and give the local directory to PPM, it should install it without problem.

    If some problem persists, don't assume the module DBD::Pg is at fault, it's probably something else: read the postgres log, it will probably bring enlightenment.

    Ah, and by the way: PostgreSQL 8.3 Release Candidate 1 is out! You may want to try that - it is already very stable, and full of new goodies: see release notes for 8.3.

    For win32: v8.3RC1 binaries

    update: 8.3 binaries ( PostgreSQL 8.3 was released 4 february 2008 ).

Re: Trouble establishing a dialogue between Perl and PostgreSQL
by talexb (Chancellor) on Jan 14, 2008 at 21:15 UTC

    Under Linux (the Windows locations will, no doubt, vary) I usually have to go into /var/lib/pgsql/data/ and modify pg_hba.conf (to allow local access without authentication) and postgresql.conf (to allow a connection using sockets).

    And, of course, if this is a new installation I have to run the service script with initdb before the service itself can be started. You platform may vary.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re: Trouble establishing a dialogue between Perl and PostgreSQL
by olus (Curate) on Jan 14, 2008 at 20:47 UTC
    Maybe you need to specify that you are connecting to localhost, and you mustn't forget about dbname.
    my $db=DBI->connect("dbi:PgPP:dbname=testdb;host=localhost", 'postgres +','xxxxxxxxx') or die DBI->errstr;
    Hope that helps.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://662370]
Approved by kyle
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2024-03-28 10:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found