0

I am working with the pg module for node. I am trying to get some rows from different tables. Often times i get an error in my tests when accessing rows because the query came back empty. In that case i would like to get the query with parameters inserted in the console so i can paste it to pgAdmin and see what is wrong easier.

I tried searching for it in the pg docs but couldnt find anything.

Is there a way to output the queries?

Siniyas
  • 443
  • 1
  • 5
  • 19
  • 1
    Related: http://stackoverflow.com/questions/36101141/postgresget-executable-query-from-query-with-parameters/36109865#36109865 – vitaly-t May 29 '16 at 23:20

1 Answers1

4

Thanks to Vitaly's comment and his library pg-promise I was able to print out the statements like described by him in this answer:

get executable query from query with parameters

Thank you Vitaly.

Community
  • 1
  • 1
Siniyas
  • 443
  • 1
  • 5
  • 19
  • Since you are developing for Node.js + PostgreSQL, you can switch over to [pg-promise](https://github.com/vitaly-t/pg-promise) completely, and not just for query formatting ;) – vitaly-t Jun 03 '16 at 09:01