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
<div class="Section1"><h2><b><font face="Arial" size="2"><span style="font-size:10.0pt;font-family:Arial;
font-weight:normal">I am also experiencing a similar problem (on Windows XP, PostgreSQL 8.0.1) using Perl, DBD::PgPP.
 Idid make the changes as was suggested by John DeSoi (i.e., provide local machine in your connect parameters,…… that
isI am presently using “localhost”). However, the error message is now changed  to the
following:</span></font></b></h2><h2><b><fontface="Arial" size="2"><span style="font-size:10.0pt;font-family:Arial; 

font-weight:normal">***************************************************************************************************</span></font></b></h2><h2><b><font
face="Arial"size="2"><span style="font-size:10.0pt;font-family:Arial; 
font-weight:normal">Couldn’t connect to localhost :5432/tcp IO::Socket::INET: Unknown error at
C:Perl/site/lib/DBD/PgPP.pmline 124</span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;

font-weight:normal">***************************************************************************************************</span></font></b></h2><h2><b><font
face="Arial"size="2"><span style="font-size:10.0pt;font-family:Arial; 
font-weight:normal">Secondly, assuming that my issue with the above error message based on someone’s reply (hopefully),
willend up being resolved (counting on “localhost”), does that mean this piece of code will always have to run on the
localmachine where PostgreSQL is installed on?!</span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal"> </span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal">I also looked at the configuration files (pg_hba.conf, & postgresql.conf), and there is not a
placeto 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
mypostmaster on Windows gets launched automatically (as a default service on Windows based on the following
line):</span></font></b></h2><h2><b><fontface="Arial" size="2"><span style="font-size:10.0pt;font-family:Arial; 
font-weight:normal"> </span></font></b></h2><p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size:
12.0pt">"C:\Program Files\PostgreSQL\8.0\bin\pg_ctl.exe" runservice -N "pgsql-8.0" -D "C:\Program
Files\PostgreSQL\8.0\data\"</span></font><h2><b><fontface="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal">  </span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal"> </span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal">Following is the code I am using, which gives the above listed error
message.</span></font></b></h2><h2><b><fontface="Arial" size="2"><span style="font-size:10.0pt;font-family:Arial; 
font-weight:normal"> </span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal">#!/usr/bin/perl -W</span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal">#</span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal">#FileName:        dbClient1.pl</span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal">#</span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal">use strict;</span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal">use DBI;</span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal">use IO::Socket;</span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal"> </span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal"> </span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal">my $user = "xyz";</span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal">my $password = "xyz_passwd";</span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal">my $dbname = "testdb";</span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal"> </span></font></b></h2><h2><b><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;
font-weight:normal">my $dbh = DBI->connect("dbi:PgPP:dbname=$dbname; localhost",</span></font></b></h2><h2><b><font
face="Arial"size="2"><span style="font-size:10.0pt;font-family:Arial; 
font-weight:normal">                                    'username=$user', 'password=$password')
</span></font></b></h2><h2><b><fontface="Arial" size="2"><span style="font-size:10.0pt;font-family:Arial; 
font-weight:normal">                                    || die "Database connection not made:    
$DBI::errstr";</span></font></b></h2><h2><b><fontface="Arial" size="1"><span style="font-size:9.0pt;font-family:Arial; 
font-weight:normal">Thanks,</span></font></b></h2><h2><b><font face="Arial" size="1"><span
style="font-size:9.0pt;font-family:Arial;
font-weight:normal">Behzad</span></font></b></h2><h2><b><font face="Arial" size="5"><span
style="font-size:18.0pt;font-family:Arial;
font-weight:normal"> </span></font></b></h2><h2><b><font face="Arial" size="5"><span
style="font-size:18.0pt;font-family:Arial">Re:making contact via perl</span></font></b></h2><div align="center"
class="MsoNormal"style="text-align:center"><font face="Times New Roman" size="3"><span style="font-size:12.0pt"><hr
align="center"color="gray" noshade size="3" width="40%" /></span></font></div><ul type="disc"><li class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;   mso-list:l1 level1 lfo3"><strong><b><font face="Arial"
size="3"><spanstyle="font-size:12.0pt;font-family:Arial">From</span></font></b></strong><font face="Arial"><span
style="font-family:Arial">:<strong><b><font face="Arial"><span style="font-family:Arial">John DeSoi <<a
href="mailto:desoi@DOMAIN.HIDDEN">desoi( at ) pgedit ( dot ) com</a>></span></font></b></strong></span></font><li
class="MsoNormal"style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;    mso-list:l1 level1
lfo3"><strong><b><fontface="Arial" size="3"><span
style="font-size:12.0pt;font-family:Arial">To</span></font></b></strong><fontface="Arial"><span
style="font-family:Arial">:<strong><b><font face="Arial"><span style="font-family:Arial">"Stephen Choularton" <<a
href="mailto:mail@DOMAIN.HIDDEN">mail( at ) bymouth ( dot ) com</a>></span></font></b></strong></span></font><li
class="MsoNormal"style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;    mso-list:l1 level1
lfo3"><strong><b><fontface="Arial" size="3"><span
style="font-size:12.0pt;font-family:Arial">Subject</span></font></b></strong><fontface="Arial"><span
style="font-family:Arial">:<strong><b><font face="Arial"><span style="font-family:Arial">Re: making contact via
perl</span></font></b></strong></span></font><liclass="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;   mso-list:l1 level1 lfo3"><font face="Arial" size="3"><span
style="font-size:   12.0pt;font-family:Arial">Date: Tue, 29 Mar 2005 22:15:40 -0500</span></font></ul><div
align="center"class="MsoNormal" style="text-align:center"><font face="Times New Roman" size="3"><span
style="font-size:12.0pt"> size=2 width="100%" align=center> </span></font></div><p class="MsoNormal"
style="margin-bottom:12.0pt"><tt><fontface="Courier New" size="2"><span style="font-size:10.0pt">You need to provide
thehost of the local machine in your connect parameters (e.g. 127.0.0.1 or localhost). The /tmp directory reference
indicatesthat perl is trying to connect with a Unix domain socket which is not supported on Windows. TCP/IP host
connectionsonly.</span></font></tt><pre><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial">JohnDeSoi, Ph.D.</span></font></pre><pre><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial"><a
href="http://pgedit.com/">http://pgedit.com/</a></span></font></pre><pre><fontface="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial">PowerTools for PostgreSQL</span></font></pre><p class="MsoNormal"
style="margin-bottom:12.0pt"><fontface="Arial" size="3"><span style="font-size:12.0pt;font-family:Arial"><br
/></span></font><fontface="Courier New" size="2"><span style="font-size:10.0pt; 
font-family:"Courier New""><br /><tt><font face="Courier New">On Mar 29, 2005, at 8:12 PM, Stephen Choularton
wrote:</font></tt></span></font><pclass="MsoNormal"><tt><font face="Courier New" size="2"><span style="font-size: 
10.0pt"># connecting to database</span></font></tt><font face="Arial"><span style="font-family:Arial"><br /><br
/></span></font><tt><fontface="Courier New" size="2"><span style="font-size:10.0pt">my
$database='mydb';</span></font></tt><fontface="Arial"><span style="font-family: 
Arial"><br /><br /></span></font><tt><font face="Courier New" size="2"><span style="font-size:10.0pt">my $username =
'postgres';</span></font></tt><fontface="Arial"><span style="font-family:Arial"><br /><br /></span></font><tt><font
face="CourierNew" size="2"><span style="font-size:10.0pt">my $password = '';</span></font></tt><font face="Arial"><span
style="font-family:
Arial"><br /><br /></span></font><tt><font face="Courier New" size="2"><span style="font-size:10.0pt">my $dbh =
DBI->connect("DBI:PgPP:$database",</span></font></tt><fontface="Arial"><span style="font-family:Arial"><br /><br
/></span></font><tt><fontface="Courier New" size="2"><span style="font-size:10.0pt">    "$username",
"$password");</span></font></tt><fontface="Arial"><span style="font-family:Arial"><br /><br /></span></font><tt><font
face="CourierNew" size="2"><span style="font-size:10.0pt"> </span></font></tt><font face="Arial"><span
style="font-family:Arial"><br/><br /></span></font><tt><font face="Courier New" size="2"><span
style="font-size:10.0pt">Iget:</span></font></tt><font face="Arial"><span style="font-family:Arial"><br /><br
/></span></font><tt><fontface="Courier New" size="2"><span style="font-size:10.0pt"> </span></font></tt><font
face="Arial"><spanstyle="font-family:Arial"><br /><br /></span></font><tt><font face="Courier New" size="2"><span
style="font-size:10.0pt">C:\DB>db.pl</span></font></tt><fontface="Arial"><span style="font-family:Arial"><br /><br
/></span></font><tt><fontface="Courier New" size="2"><span style="font-size:10.0pt">DBI connect('mydb','postgres',...)
failed:Couldn't connect to /tmp/.s.PGSQL.543</span></font></tt><font face="Arial"><span style="font-family:Arial"><br
/><br/></span></font><tt><font face="Courier New" size="2"><span style="font-size:10.0pt">2:  at
C:/Perl/site/lib/DBD/PgPP.pmline 124</span></font></tt><font face="Arial"><span style="font-family:Arial"><br /><br
/></span></font><tt><fontface="Courier New" size="2"><span style="font-size:10.0pt"> at C:\DB\db.pl line 15
</span></font></tt><pclass="MsoNormal"><font face="Arial" size="3"><span style="font-size:12.0pt; 
font-family:Arial"><br /><br /><br /><br /></span></font><div align="center" class="MsoNormal"
style="text-align:center"><fontface="Times New Roman" size="3"><span style="font-size:12.0pt"><hr align="center"
size="2"width="100%" /></span></font></div><ul type="disc"><li class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;   mso-list:l4 level1 lfo4"><strong><b><font face="Arial"
size="3"><spanstyle="font-size:12.0pt;font-family:Arial">References</span></font></b></strong><font face="Arial"><span
style="font-family:Arial">:</span></font><ul type="circle"><li class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:    auto;mso-list:l4 level2 lfo4"><a name="00323"></a><a
href="http://archives.postgresql.org/pgsql-novice/2005-03/msg00323.php"><b><fontface="Arial"><span
style="font-family:Arial;font-weight:bold">makingcontact via perl</span></font></b></a><font face="Arial"><span
style="font-family:Arial"></span></font><ul type="square"><li class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:     auto;mso-list:l4 level3 lfo4"><em><i><font face="Arial"
size="3"><spanstyle="font-size:12.0pt;font-family:Arial">From:</span></font></i></em><font face="Arial"><span
style="font-family:Arial">Stephen Choularton</span></font></ul></ul></ul><div align="center" class="MsoNormal"
style="text-align:center"><fontface="Times New Roman" size="3"><span style="font-size:12.0pt">  size=2 width="100%"
align=center></span></font></div><ul type="disc"><li class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;   mso-list:l0 level1 lfo5"><font face="Arial" size="3"><span
style="font-size:   12.0pt;font-family:Arial">Prev by Date: <strong><b><font face="Arial"><span
style="font-family:Arial"><ahref="http://archives.postgresql.org/pgsql-novice/2005-03/msg00323.php">making contact via
perl</a></span></font></b></strong></span></font><li class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;   mso-list:l0 level1 lfo5"><font face="Arial" size="3"><span
style="font-size:   12.0pt;font-family:Arial">Next by Date: <strong><b><font face="Arial"><span
style="font-family:Arial"><ahref="http://archives.postgresql.org/pgsql-novice/2005-03/msg00325.php">Re: Connecting to
databaseusing pg_connect</a></span></font></b></strong> </span></font><li class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;   mso-list:l0 level1 lfo5"><font face="Arial" size="3"><span
style="font-size:   12.0pt;font-family:Arial">Previous by thread: <strong><b><font face="Arial"><span
style="font-family:Arial"><ahref="http://archives.postgresql.org/pgsql-novice/2005-03/msg00323.php">making contact via
perl</a></span></font></b></strong></span></font><li class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;   mso-list:l0 level1 lfo5"><font face="Arial" size="3"><span
style="font-size:   12.0pt;font-family:Arial">Next by thread: <strong><b><font face="Arial"><span
style="font-family:Arial"><ahref="http://archives.postgresql.org/pgsql-novice/2005-03/msg00326.php">Quote
Question</a></span></font></b></strong></span></font></ul><p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size:10.0pt;
font-family:Arial"> </span></font></div>

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