making contact via perl

Lists: pgsql-novice
From: "Stephen Choularton" <mail(at)bymouth(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: making contact via perl
Date: 2005-03-30 01:12:33
Message-ID: 000001c534c5$92540a30$9701a8c0@Tablet
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Hi

I appreciate this may not be the right place to post. If it isn’t
please advise me of the correct site.

I am using windowsXP. I am trying to make contact with a psql database
called mydb that is on my computer. I can do this at the prompt, viz:

C:\Documents and Settings\Stephen>psql mydb postgres
Welcome to psql 8.0.1, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

Warning: Console code page (437) differs from Windows code page (1252)
8-bit characters may not work correctly. See psql reference
page "Notes for Windows users" for details.

And I know it is there:

^
mydb=# select * from weather;
city | temp_lo | temp_hi | prcp | date
---------------+---------+---------+------+------------
San Francisco | 46 | 50 | 0.25 | 1994-11-27
Hayward | 37 | 54 | | 1994-11-29
(2 rows)

but when I try to use this perl code to make contact:

use DBI;

use DBD::PgPP

my @drivers = DBI -> available_drivers();

print "this is it @drivers";



# 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

Stephen

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.4 - Release Date: 27/03/2005


From: John DeSoi <desoi(at)pgedit(dot)com>
To: "Stephen Choularton" <mail(at)bymouth(dot)com>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: making contact via perl
Date: 2005-03-30 03:15:40
Message-ID: FEE7B6AC-A0C9-11D9-A297-000A95B03262@pgedit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

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