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
6
votes
1 answer

How to set query_timeout in relation to statement_timeout?

We can set 2 timeouts for the Client: statement_timeout: number of milliseconds before a statement in query will time out, default is no timeout query_timeout number of milliseconds before a query call will timeout, default is no timeout I…
TmTron
  • 17,012
  • 10
  • 94
  • 142
6
votes
4 answers

How to set schema with node-postgres

I'm trying to query against a schema called DOCUMENT in my postgres db using node-postgres. I can't seem to get a query to run against the specified schema. This query runs fine directly against postgres using psql SELECT * FROM…
Catfish
  • 18,876
  • 54
  • 209
  • 353
6
votes
2 answers

postgres composite type on node-postgres

Say I have the following postgreSQL composite type: CREATE TYPE myType AS( id bigint, name text, ); and a stored procedure that excepts that type: CREATE FUNCTION myFunction(mt myType){ //do some stuff } I would like to call this procedure…
Yaki Klein
  • 3,978
  • 3
  • 37
  • 34
6
votes
1 answer

Error installing node-postgres on Amazon Linux. Missing pg_config.h file

This error seems common on windows boxes, but my Amazon Linux EC2 instance is throwing this error when I npm install pg: ../src/binding.cc:1:23: fatal error: pg_config.h: No such file or directory #include
kdbanman
  • 10,161
  • 10
  • 46
  • 78
6
votes
4 answers

Manually promisifying pg.connect with Bluebird

I want to promisify node-postgres' pg.connect method along with the inner connection.query method provided in the callback. I can .promisify the latter, but I need to implement the first one manually (if I'm missing something here, please…
luisfarzati
  • 8,649
  • 6
  • 29
  • 27
6
votes
3 answers

Node.js / Express - How to get variables defined in app.js in routes/index.js?

I'm new to Node.js and Express. How can I access the variable created in "app.js" called "pg" in "routes/index.js"? app.js /** * Module dependencies. */ var express = require('express'); var routes = require('./routes'); var user =…
André
  • 24,706
  • 43
  • 121
  • 178
6
votes
1 answer

Node-postgres date not saving accurately

I'm using Node.js, Postgres, and the node-postgres library. When I try to insert a new record with the current date with code like this: client.query('INSERT INTO ideas(date) VALUES($1)', [new Date()], ...); And this runs fine with no errors.…
maxluzuriaga
  • 1,327
  • 9
  • 16
5
votes
1 answer

node-postgres how to escape parameters?

I know about parameterized query, but since I have to programmatically construct the where condition, taking count of the parameters and building the parameters array is a task much more complex than simply calling an escape function when required.…
Daniele Ricci
  • 15,422
  • 1
  • 27
  • 55
5
votes
1 answer

Jest TLSWRAP open handle error using simple node-postgres pool.query() fixed with setTimeout delay, but why?

When I run the following test: afterAll(async () => { await runDbBuild(); await pool.end(); }); describe("queries.newteetypes.select.all():", () => { test("Test 1: object keys ", async () => { const awaitedResponse =…
JimmyTheCode
  • 3,783
  • 7
  • 29
  • 71
5
votes
2 answers

How to setup postgres database and tables in node pg

I want to share a Node repo, and ideally it should be ready to use after the usual yarn install && yarn start. However pg can't connect neither SELECT to/from a database and table that don't exist yet. It's a hassle but at the moment these previous…
Mikel
  • 5,902
  • 5
  • 34
  • 49
5
votes
5 answers

Node.js - PostgreSQL (pg) : Client has already been connected. You cannot reuse a client

I am just trying to write simple register/login system. I am trying to find if username exists. Here is the steps : Go localhost:3000/users/register page Fill in all fields and click register button Checking my command line if username exists it…
Oxibital
  • 135
  • 1
  • 2
  • 10
5
votes
1 answer

Postgres server is not responding to a nodejs request

I have access to a remote postgres DB from pgAdmin4 and I also could access from nodejs using a Mac. Right now I'm using the same code to access the DB in Windows. The code for my connection is the following: const { Client } = require('pg');…
Maf
  • 696
  • 1
  • 8
  • 23
5
votes
1 answer

TypeScript compile problems with node-postgres

Disclaimer up-front, I'm fairly new to TypeScript so this may be a dumb question! I'm attempting to use the same setup for my Express/Postgres application as described in the node-postgres docs, where I have a single module that connects to the…
VirtualWolf
  • 653
  • 13
  • 23
5
votes
1 answer

Using Ngrok to connect to local PostgreSQL from AWS Lamba

I'm trying to use node-postgres (PG) to connect to my localhost PostgreSQL database running on port 5432. To do this, I've setup ngrok to tunnel my request. ./ngrok tcp 5432 The code below works when running locally (even when tunneling using…
Will Lovett
  • 1,241
  • 3
  • 18
  • 35
5
votes
1 answer

Node - Postgres driver setup with node-postgres

I am trying to integrate node-postgres driver and learn to do a simple CRUD operations. In my app.js, I do something like this: ... var postgres = require('./adapters/postgres') var postClient = new postgres(conf); ... postClient.connect(function…
JackSlayer94
  • 805
  • 3
  • 16
  • 38