Re: making contact via perl - Mailing list pgsql-interfaces

From Behzad Mahini
Subject Re: making contact via perl
Date
Msg-id 5122464168183D4FAB69535A590159C965354B@us-red-corp1.monosphere.com
Whole thread Raw
List pgsql-interfaces

I am also experiencing a similar problem (on Windows XP, PostgreSQL 8.0.1) using Perl, DBD::PgPP.  I did make the changes as was suggested by John DeSoi (i.e., provide local machine in your connect parameters,…… that is I am presently using “localhost”). However, the error message is now changed  to the following:

***************************************************************************************************

Couldn’t connect to localhost :5432/tcp IO::Socket::INET: Unknown error at C:Perl/site/lib/DBD/PgPP.pm line 124

***************************************************************************************************

Secondly, assuming that my issue with the above error message based on someone’s reply (hopefully), will end up being resolved (counting on “localhost”), does that mean this piece of code will always have to run on the local machine where PostgreSQL is installed on?!

 

I also looked at the configuration files (pg_hba.conf, & postgresql.conf), and there is not a place to make changes to address TCP-IP connections (on Windows). Additionally, PostgreSQL documentation warns about running “postmaster” with the –i option (& I did not find this to be relevant to the Windows environment). Presently my postmaster on Windows gets launched automatically (as a default service on Windows based on the following line):

 

"C:\Program Files\PostgreSQL\8.0\bin\pg_ctl.exe" runservice -N "pgsql-8.0" -D "C:\Program Files\PostgreSQL\8.0\data\"

  

 

Following is the code I am using, which gives the above listed error message.

 

#!/usr/bin/perl -W

#

#FileName:        dbClient1.pl

#

use strict;

use DBI;

use IO::Socket;

 

 

my $user = "xyz";

my $password = "xyz_passwd";

my $dbname = "testdb";

 

my $dbh = DBI->connect("dbi:PgPP:dbname=$dbname; localhost",

                                    'username=$user', 'password=$password')

                                    || die "Database connection not made:     $DBI::errstr";

Thanks,

Behzad

 

Re: making contact via perl


size=2 width="100%" align=center>

You need to provide the host of the local machine in your connect parameters (e.g. 127.0.0.1 or localhost). The /tmp directory reference indicates that perl is trying to connect with a Unix domain socket which is not supported on Windows. TCP/IP host connections only.

John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL



On Mar 29, 2005, at 8:12 PM, Stephen Choularton wrote:

# connecting to database

my $database='mydb';

my $username = 'postgres';

my $password = '';

my $dbh = DBI->connect("DBI:PgPP:$database",

    "$username", "$password");

 

I get:

 

C:\DB>db.pl

DBI connect('mydb','postgres',...) failed: Couldn't connect to /tmp/.s.PGSQL.543

2:  at C:/Perl/site/lib/DBD/PgPP.pm line 124

 at C:\DB\db.pl line 15






size=2 width="100%" align=center>

 

pgsql-interfaces by date:

Previous
From: Ashley Clark
Date:
Subject: Re: Apple xCode 2.0 and linking with libpq.a
Next
From: sara simoes
Date:
Subject: Migrate data from Access to PostgreSQL