Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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/ 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


#!/usr/bin/perl -W




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",


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




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. 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.
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:



DBI connect('mydb','postgres',...) failed: Couldn't connect to

2:  at C:/Perl/site/lib/DBD/ line 124

 at C:\DB\ line 15 


*	References: 

	*	making contact via perl

		*	From: Stephen Choularton


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

*	Prev by Date: making contact via perl
*	Next by Date: Re: Connecting to database using pg_connect
*	Previous by thread: making contact via perl
*	Next by thread: Quote Question


pgsql-interfaces by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group