From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Good <tomg@admin.nrnet.org>
Cc: Kate Collins <klcollins@wsicorp.com>
Cc: kris@grinz.com
Cc: pgsql-sql@postgresql.org
Subject: Re: prob with PERL/Postgres
Date: Mon, 06 Aug 2001 17:39:15 -0400
Message-ID: <24707.997133955@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.LNX.4.05.10108061713200.29068-100000@admin.nrnet.org>
References: <Pine.LNX.4.05.10108061713200.29068-100000@admin.nrnet.org>
Thomas Good <tomg@admin.nrnet.org> writes:
> Kate, he uses a diff module by the same author (Edmund Mergl) but with
> a very diff syntax. The advantage of the DBI - Kris, if you're
> interested - is that the syntax is much like ESQL/C and the code is
> much more portable. For example I use DBI to access both pg and
> oracle.
DBI is a good alternative, but is unlikely to act much differently as
far as connection problems go.
> 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.
It's hard to tell with only that much information. I think the real
mistake in this code is not checking for failure of the connectdb()
call. Had you checked at that point, you would have gotten a more
useful error message. The examples in the Pg documentation recommend
$conn = Pg::connectdb(whatever);
die $conn->errorMessage unless PGRES_CONNECTION_OK eq $conn->status;
Try that, and if you're still in the dark, let us see the error
message...
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, tomg@admin.nrnet.org, klcollins@wsicorp.com, kris@grinz.com
Subject: Re: prob with PERL/Postgres
In-Reply-To: <24707.997133955@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox