Received: from smartt.com (ktk6.smartt.com [209.52.5.253]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f76KXL621985 for ; Mon, 6 Aug 2001 16:33:21 -0400 (EDT) (envelope-from drfrog@smartt.com) Received: from smartt.com (alpnb13234.smarttadsl.com [209.52.133.234]) by smartt.com (8.11.1/8.11.1) with ESMTP id f76Kij129626; Mon, 6 Aug 2001 13:44:45 -0700 (PDT) Message-ID: <3B6F0009.2060909@smartt.com> Date: Mon, 06 Aug 2001 13:37:29 -0700 From: clayton User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.1) Gecko/20010607 X-Accept-Language: en-us MIME-Version: 1.0 To: kris@grinz.com CC: pgsql-sql@postgresql.org Subject: Re: prob with PERL/Postgres References: <3B6EA444.13097.C20296@localhost> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200108/65 X-Sequence-Number: 4286 Kristopher Yates wrote: >PERL SNIPPET: > ># build arrays from file (OMITTED) > >use Pg; >$dbhost='127.0.0.1'; >$dbname='mpact'; >#$connstr="dbname=$dbname"; >$connstr="host=$dbhost dbname=$dbname"; >$conn = Pg::connectdb($connstr); > >#more code related to date omitted > > $result=$conn->exec($sql); > (PGRES_COMMAND_OK eq $result->resultStatus) > or die $conn->errorMessage; > >WHY DO I GET PQsendQuery() -- There is no connection to the >backend. I have tried leaving host blank, using IP 127.0.0.1 and >hostname localhost. This script should work - the problem is >something with postgres but I dont know what. Any ideas out >there? Thanks, Kris > >---------------------------(end of broadcast)--------------------------- >TIP 5: Have you checked our extensive FAQ? > >http://www.postgresql.org/users-lounge/docs/faq.html > > have you checked your /etc/host file? as well is your loopback on ? what about your pg_hba.conf it should probably have ,by default: ---pg_hba.conf---- # By default, allow anything over UNIX domain sockets and localhost. local all trust host all 127.0.0.1 255.255.255.255 trust ---pg_hba.conf---- you can use stonger security consult the Pg docs on that! its been a while since ive looked at them here is how i connect:: #!/usr/bin/perl use strict; use warnings; use Pg; my $command="select * from write;"; my $conninfo = "dbname=write user=www password=Apache1312 host=localhost"; my $conn = Pg::connectdb($conninfo); if (Pg::PGRES_CONNECTION_OK == $conn->status){ my $result = $conn->exec($command); if (Pg::PGRES_TUPLES_OK == $result->resultStatus) { while (my @row = $result->fetchrow) { print join (" ",@row); } } }