Re: making contact via perl

From: "Behzad Mahini" <behzad(at)monosphere(dot)com>
To: <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: making contact via perl
Date: 2005-06-18 19:46:17
Message-ID: 5122464168183D4FAB69535A590159C965354B@us-red-corp1.monosphere.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

_____

* From: John DeSoi <desoi ( at ) pgedit ( dot ) com
<mailto:desoi(at)DOMAIN(dot)HIDDEN> >
* To: "Stephen Choularton" <mail ( at ) bymouth ( dot ) com
<mailto:mail(at)DOMAIN(dot)HIDDEN> >
* Subject: Re: making contact via perl
* Date: Tue, 29 Mar 2005 22:15:40 -0500

_____

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

_____

* References:

* making contact via perl
<http://archives.postgresql.org/pgsql-novice/2005-03/msg00323.php>

* From: Stephen Choularton

_____

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

* Prev by Date: making contact via perl
<http://archives.postgresql.org/pgsql-novice/2005-03/msg00323.php>
* Next by Date: Re: Connecting to database using pg_connect
<http://archives.postgresql.org/pgsql-novice/2005-03/msg00325.php>
* Previous by thread: making contact via perl
<http://archives.postgresql.org/pgsql-novice/2005-03/msg00323.php>
* Next by thread: Quote Question
<http://archives.postgresql.org/pgsql-novice/2005-03/msg00326.php>

Browse pgsql-interfaces by date

  From Date Subject
Next Message sara simoes 2005-06-20 10:54:55 Migrate data from Access to PostgreSQL
Previous Message Ashley Clark 2005-06-16 20:11:04 Re: Apple xCode 2.0 and linking with libpq.a