Questions tagged [node-postgres]

Node-postgres is a postgresql client module for node.js applications to interact with postgresql databases.

About

Node-postgres is a postgresql client module for node.js applications to interact with postgresql databases.

Its source code and wiki can be found on GitHub.

587 questions
5
votes
2 answers

Connection pool using pg-promise

I'm using Node js and Postgresql and trying to be most efficient in the connections implementation. I saw that pg-promise is built on top of node-postgres and node-postgres uses pg-pool to manage pooling. I also read that "more than 100 clients at…
michalDia
  • 61
  • 1
  • 6
5
votes
2 answers

Reusing pg-pool via module exports

After reading the docs: https://github.com/brianc/node-pg-pool, I am slightly concerned about reusing the new Pool() method. The docs suggests that I need to place the new Pool() before exports and return it like so // db.js const pool = new…
Antartica
  • 125
  • 9
5
votes
1 answer

Node-Postgres query method not calling its callback function

I have the following code which uses node-postgres: var client = new pg.Client(conString); client.connect(function(err) { if(err) { throw new Error(console.error('could not connect to postgres '+ err)); } …
DanB91
  • 1,399
  • 1
  • 13
  • 23
5
votes
1 answer

postgres connection from node.js

I am using node-postgres in my application. I would like to know the best practices that I want to follow to ensure the stable connection. following is the code I'm using right now, exports.getAll = function (args, callback) { helper.client = new…
started on node.js
  • 607
  • 1
  • 8
  • 14
5
votes
1 answer

does node-postgres support multiple resultsets

I have a PostgresQL function that returns multiple resultsets. I can extract these resultsets in .net without a problem (so I know my function works correctly), but I am having trouble doing so with node-postgres. The result object returns an array…
AlexGad
  • 6,612
  • 5
  • 33
  • 45
4
votes
1 answer

In node.js, why one would want to use pools when connecting through node-postgres?

With node-postgres npm package, I'm given two connection options: with using Client or with using Pool. What would be the benefit of using a Pool instead of a Client, what problem will it solve for me in the context of using node.js, which is a)…
Meglio
  • 1,646
  • 2
  • 17
  • 33
4
votes
1 answer

SvelteKit endpoint: converting from Node/Express

New to SvelteKit and working to adapt an endpoint from a Node/Express server to make it more generic so as to be able to take advantage of SvelteKit adapters. The endpoint downloads files stored in a database via node-postgresql. My functional…
nstuyvesant
  • 1,392
  • 2
  • 18
  • 43
4
votes
1 answer

Pooling, Client Checked out, idleTimeoutMillis

This is my understanding after reading the Documents: Pooling, like many other DBs, we have only a number of allowed connections, so you guys all line-up and wait for a free connection returned to the pool. (a connection is like a token in a…
Jeb50
  • 6,272
  • 6
  • 49
  • 87
4
votes
2 answers

Postgresql - Error Connection terminated due to connection timeout

I have created a google cloud function in google cloud which will connect to my postgresql instance created in Google cloud. I am using 'pg' node module. I have create a private IP for this. I am getting following error: Error: Connection…
Rekha
  • 59
  • 1
  • 7
4
votes
2 answers

Fetch all tables in a particuler Postgres database using node?

I need to fetch all tables in a particular Postgres database using node. But not finding any way to achieve that. Is there any way to get that? For example, suppose I have a database named 'TestDatabase' it contains 4 tables( just assume it can have…
Anuresh Verma
  • 818
  • 1
  • 13
  • 30
4
votes
2 answers

Why is node-postgres (pg) hanging when I call client.connect()?

I recently had to upgrade my node.js version for my vue.js application (node.js on the backend) from v13.5.0 to v14.5.0. I reinstalled all my node packages, upgrading the ones I had to upgrade, and now the application hangs on all DB calls. We are…
gib65
  • 1,709
  • 3
  • 24
  • 58
4
votes
1 answer

How to catch for client.connect() in node-postgres?

try/catch does not work for client.connect(): const { Pool, Client } = require('pg') try { const client = new Client(config) client.connect() } catch (er) { console.log('error') } Error: UnhandledPromiseRejectionWarning: error: password…
Henry
  • 1,077
  • 1
  • 16
  • 41
4
votes
1 answer

Difficulty connecting to PostgreSQL@localhost using node-postgress (Error:28000)

I'm currently running openSuse on an rPi3B+ (aarch64) and have hit a wall running a NodeJS connection script. I went through the standard install of PostgreSQL (v10 is what is offered on this version of openSuse) then created a new role with CREATE…
AustinFoss
  • 385
  • 5
  • 13
4
votes
0 answers

Bulk psql data COPY from stdin in nodeJs

I need to load the data in psql db time-to-time via a node app. I'm using node-postgres package, which seems to be working fine with INSERT statements. Since my db_dum is huge, I need to move to COPY statement in pg_dump (for better performance),…
Mahyar
  • 1,011
  • 2
  • 17
  • 37
4
votes
1 answer

how to disconnect a pool in pg module

So, I use the pg module in node 8.11.1 / express 4.16.3 / pg 7.4.2 I try to use the pool for my front-end (just selects) and the examples are somewhat confusing. In connecting it uses just a new Pool and then it shows that I have to do…
codebot
  • 517
  • 8
  • 29
  • 55