node-postgres Questions

2

Solved

i am using nodejs as my REST api host. The overall functionality is pretty basic. that is, make a REST call which should do a postgres db query and return data. The problem I am having is the overa...
Sola asked 20/6, 2017 at 4:7

3

Solved

From https://node-postgres.com/features/connecting , seems like we can choose between Pool or Client to perform query pool.query('SELECT NOW()', (err, res) => { console.log(err, res) pool.end...
Gradus asked 12/2, 2018 at 16:49

2

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...
Countable asked 6/3, 2021 at 1:10

1

Solved

I have a table that looks like this: CREATE TABLE IF NOT EXISTS list ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), tok TEXT, sid TEXT NOT NULL, aid TEXT, hash TEXT, qtt SMALLINT, p ...
Langmuir asked 23/11, 2023 at 20:42

3

I have stored input data in date format in postgres database, but when I am showing the date in browser it's showing date with timezone and converting it from utc. For example I have stored the dat...
Elwood asked 15/7, 2020 at 20:14

6

Solved

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 butt...
Loutish asked 24/7, 2020 at 13:34

5

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 ...
Tertias asked 22/5, 2019 at 17:30

10

I am trying to connect to my Heroku PostgreSQL DB and I keep getting an SSL error. Does anyone have an idea on how to enable SSL in the connection string? postgres://user:pass@host:port/database; ...
Juggler asked 10/3, 2014 at 13:37

3

Here's the route from which the query is being executed: userRouter.route("/new") .post(function (req, res) { var user = req.body; pg.connect(connectionString, function (error, client, done) { ...
Cloe asked 23/1, 2016 at 17:59

2

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...
Squalid asked 29/4, 2022 at 11:57

2

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(conf...
Alfons asked 8/12, 2020 at 14:23

6

Solved

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 subscription...
Attractive asked 3/6, 2014 at 6:44

8

Solved

I'm trying to execute a query like this: SELECT * FROM table WHERE id IN (1,2,3,4) The problem is that the list of ids I want to filter against is not constant and needs to be different at every...
Sanorasans asked 23/5, 2012 at 12:58

8

Solved

A single row can be inserted like this: client.query("insert into tableName (name, email) values ($1, $2) ", ['john', '[email protected]'], callBack) This approach automatically comments ou...
Lymphocyte asked 25/1, 2016 at 10:24

10

I'm trying to connect to a remote database using node-postgres. I can connect using the psql client, but I get the error Connection terminated unexpectedly while trying to run this (with same conn...
Johnajohnath asked 6/4, 2018 at 16:18

3

Solved

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...
Macaw asked 12/2, 2014 at 21:53

2

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 nam...
Desensitize asked 18/3, 2016 at 17:35

5

Solved

I'm looking for an efficient way to take a raw sql file and have it executed synchronously against a postgres database, akin to if you ran it through psql. I have an sql file which creates all dat...
Knowhow asked 25/3, 2014 at 13:40

4

Trying to bundle the following file with Webpack fails with ERROR in ./~/pg/lib/native/index.js Module not found: Error: Cannot resolve module 'pg-native' in .../node_modules/pg/lib/native @...
Gratifying asked 7/1, 2017 at 14:53

8

Solved

I'm developing a Node.js application using PostgreSQL and hosting on Heroku. My problem is that I get an authentication error like so: 14:32:05 web.1 | { [error: no pg_hba.conf entry for host "193...
Erdrich asked 23/4, 2012 at 11:49

4

Solved

I used to name my parameters in my SQL query when preparing it for practical reasons like in php with PDO. So can I use named parameters with node-postgres module? For now, I saw many examples an...
Nuclei asked 16/9, 2015 at 13:37

1

Solved

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 th...
Colored asked 2/1, 2022 at 13:15

4

How does one correctly provide the table name if the name can be dynamically determined and still prevent SQL injection attacks? I am using node-postgres. For example: The following works but I bel...
Engage asked 7/6, 2016 at 18:24

1

When I run the following test: afterAll(async () => { await runDbBuild(); await pool.end(); }); describe("queries.newteetypes.select.all():", () => { test("Test 1: object k...
Cauda asked 15/11, 2021 at 14:56

1

I'm using Next.js for my side project. I have a PostrgeSQL database hosted on ElephantSQL. Inside the Next.js project, I have a GraphQL API set up, using the apollo-server-micro package. Inside the...
Spenser asked 27/9, 2020 at 21:37

© 2022 - 2025 — McMap. All rights reserved.