0

My desktop application uses Postgres authentication and keeps permanent connection to Postgres, so every query is executed by specific user. All queries send by a single instance of the application have to be executed in the same Postgres session. A session can last up to several hours and for most of the time it can be idle.

I would like to get the same functionality using pg-promise. After some tests with express/pg-promise I'm a bit confused as I cannot find a way to do that. I'm new to web development so please an easy answer for a beginner.

Adam Piotrowski
  • 2,945
  • 3
  • 20
  • 23
  • You can't find the way? It's all documented there, right at the beginning: https://github.com/vitaly-t/pg-promise/wiki/Connection-Syntax#configuration-object, parameter `application_name`. – vitaly-t Feb 03 '17 at 11:48
  • The question was unclear, sorry. It's not about setting the parameter `application_name` but rather how to get persistent connection to the database and how to keep the login information of multiple sessions on the server side. – Adam Piotrowski Feb 03 '17 at 12:04
  • Solutions based on a persistent connection cannot scale at all. One normally uses connections from a connection pool, which is what `pg-promise` does by default. For unique case scenarios you can maintain a fixed connection via method [Database.connect](http://vitaly-t.github.io/pg-promise/Database.html#.connect). – vitaly-t Feb 03 '17 at 12:39

0 Answers0