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
10
votes
3 answers

How to optimize Postgresql max_connections and node-postgres connection pool?

In brief, I am having trouble supporting more than 5000 read requests per minute from a data API leveraging Postgresql, Node.js, and node-postgres. The bottleneck appears to be in between the API and the DB. Here are the implmentation details. I'm…
rgwozdz
  • 1,093
  • 2
  • 13
  • 26
10
votes
2 answers

Webpack can not use __dirname?

I am trying to use node-postgres to hook my app up to Postgres. The code I use is: import React from 'react'; import pg from 'pg'; import fs from 'fs'; var cn = { host: 'localhost', // server name or IP address; port: 5432, database:…
neallred
  • 740
  • 1
  • 8
  • 24
10
votes
2 answers

node-postgres with massive amount of queries

I just started playing around with node.js with postgres, using node-postgres. One of the things I tried to do is to write a short js to populate my database, using a file with about 200,000 entries. I noticed that after sometime (less than 10…
Daniel Sutantyo
  • 183
  • 1
  • 1
  • 9
9
votes
2 answers

Node-Postgres Error: timeout exceeded when trying to connect

We have a production deployed Node js application which services a good amount of traffic throught the day. The application is in loopback and connects to postgres db as with its postgres connector. The connector leverages Node-Postgres as its pg…
raman077
  • 117
  • 1
  • 7
9
votes
3 answers

Returning the result of a node-postgres query

I am attempting to return the result of a node-postgres query and store it in a variable. I can manage a console.log just fine, but cannot find a way to return the result so that it is accessible outside of the query method. I'm at a loss, and…
NJerseyBoy
  • 91
  • 1
  • 1
  • 2
9
votes
3 answers

node server can't connect to postgres db

I recently switched from MySQL to postgres as my database for an node.js project. While I'm able to reach my remote postgres database from my local pgAdmin III (OSX) client, so far I've been unable to connect to my database through node.js. I'm sure…
Dani
  • 2,448
  • 8
  • 27
  • 44
9
votes
3 answers

node-postgres: how to prepare a statement without executing the query?

I want to create a "prepared statement" in postgres using the node-postgres module. I want to create it without binding it to parameters because the binding will take place in a loop. In the documentation i read : query(object config, optional…
Jerome WAGNER
  • 21,986
  • 8
  • 62
  • 77
8
votes
6 answers

Bulk insert into Postgres with brianc/node-postgres

I have the following code in nodejs that uses the pg (https://github.com/brianc/node-postgres) My code to create subscriptions for an employee is as such. client.query( 'INSERT INTO subscriptions (subscription_guid, employer_guid,…
lonelymo
  • 3,972
  • 6
  • 28
  • 36
7
votes
1 answer

How to add an SSL certificate (ca-cert) to node.js environment variables in order to connect to Digital Ocean Postgres Managed Database?

I am currently using node-postgres to create my pool. This is my current code: const { Pool } = require('pg') const pgPool = new Pool({ user: process.env.PGUSER, password: process.env.PGPASSWORD, host: process.env.PGHOST, database:…
Petey
  • 2,819
  • 1
  • 14
  • 23
7
votes
2 answers

Get informative stack trace in node-pg

I am using node-pg with typescript. I have a getPool utility from the doc https://node-postgres.com/features/pooling export const getPool = (config?: PoolConfig) => { const pool = new Pool(config); pool.on('error', (err, client) => { …
Yann Pellegrini
  • 793
  • 3
  • 7
  • 19
7
votes
1 answer

Node.js, transaction coflicts in PostgreSQL, optimistic concurrency control and transaction retries

I want to use PostgreSQL transaction isolation to ensure data correctness with optimistic concurrency control pattern where conflicting transactions are automatically retried, instead of my application doing upfront locking of database rows and…
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
7
votes
2 answers

How to set right date format for editable-date

I getting some date fileds from postgres with format like: "2000-11-30T14:00:00.000Z" I can't use this in my editable-date field on page. Something like:
Maksim Nesterenko
  • 5,661
  • 11
  • 57
  • 91
7
votes
1 answer

node.js, pg, postgresql and insert queries (app hangs)

I have the following simple node application for data insertion into postgres database: var pg = require('pg'); var dbUrl = 'tcp://user:psw@localhost:5432/test-db'; pg.connect(dbUrl, function(err, client, done) { for (var i = 0; i < 1000; i++)…
Darius Kucinskas
  • 10,193
  • 12
  • 57
  • 79
7
votes
4 answers

What kind of object is node-postgres Error? Why node's console.log and JSON.stringify handle it differently?

console.log outputs it like this, { [error: syntax error at or near "step"] length: 86, name: 'error', severity: 'ERROR', code: '42601', detail: undefined, hint: undefined, position: '62', internalPosition: undefined, …
fedd
  • 880
  • 12
  • 39
6
votes
1 answer

How to connect to Postgres from Github Codespaces

I am experimenting with GitHub Codespaces, trying to spin up an app using Node and Postgres. I selected the following option: which produced the following devcontainer.json: // Update the VARIANT arg in docker-compose.yml to pick a Node.js version:…
1 2
3
39 40