Received: from sss.pgh.pa.us ([192.204.191.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f76Ldh648174 for ; Mon, 6 Aug 2001 17:39:43 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id f76LdFY24710; Mon, 6 Aug 2001 17:39:15 -0400 (EDT) To: Thomas Good cc: Kate Collins , kris@grinz.com, pgsql-sql@postgresql.org Subject: Re: prob with PERL/Postgres In-reply-to: References: Comments: In-reply-to Thomas Good message dated "Mon, 06 Aug 2001 17:14:50 -0400" Date: Mon, 06 Aug 2001 17:39:15 -0400 Message-ID: <24707.997133955@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200108/69 X-Sequence-Number: 4290 Thomas Good 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