Thursday, 4 May 2017

Log specific postgresql query using pg-promise

I am using pg-promise package with Nodejs to execute PostgreSQL queries. I want to see the queries executed. Only specific queries, say, just one query that I want to debug.

I can see that one recommended way is to use the pg-monitor to catch the events and log them as mentioned here in the examples documentation.

Without using pg-monitor, is there a simple way to just print the prepared query that is executed. I can't see it in the docs.

Example:

db.query("SELECT * FROM table WHERE id=$/id/", {id: 2})...;

How to print this query to yield

SELECT * FROM table WHERE id=2; 



via Maven

No comments:

Post a Comment