Re: prob with PERL/Postgres
От | Tom Lane |
---|---|
Тема | Re: prob with PERL/Postgres |
Дата | |
Msg-id | 24707.997133955@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: prob with PERL/Postgres (Thomas Good <tomg@admin.nrnet.org>) |
Ответы |
Re: prob with PERL/Postgres
|
Список | pgsql-sql |
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
В списке pgsql-sql по дате отправления: