Node-postgres is a postgresql client module for node.js applications to interact with postgresql databases.
1
vote
1answer
25 views
Get time that all query finished
function runAll(){
for (var i = 0; i < Math.random(); i++) {
pool.connect(function(err, client, done) {
client.query("update box set gamer_id=null where box_id=$1; ", [i],...
10
votes
0answers
168 views
PostgreSQL tuple format
Is there any document describing the tuple format that PostgreSQL server adheres to? The official documentation appears arcane about this.
A single tuple seems simple enough to figure out, but when ...
2
votes
0answers
61 views
Timestamptz, same point in time but different representation for same query with 'set local time zone'
I am trying to build my web app that will store the data on a PostgreSQL database server running on some location on Earth and will have users connecting from other locations, so probably different ...
2
votes
1answer
60 views
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 ...
1
vote
1answer
20 views
Knex saves date incorrectly
I have a date field set with table.date('day'); in knex schema. When I insert it with knex('table_name').insert({ someOtherData, day: '2016-08-14'}) and then use knex.select('day').from('table_name') ...
2
votes
1answer
48 views
How to convert MySQL-style question mark `?` bound parameters to Postgres-style `$1` bound parameter
I am converting an existing project from MySQL to Postgres. There are quite a few raw SQL literals in the code that use ? as a placeholder, e.g.
SELECT
id
FROM
users
WHERE
name = ?
...
0
votes
1answer
26 views
node-postgres: Update more than one record at once
I'm building an app in node.js using node-postgres. I don't know how to update more than one record at once. Here is my code:
var status = 20;
var id = [23,12,43];
pool.connect(function(err, client, ...
0
votes
1answer
28 views
PostgreSQL node.js prepared statements maximum bindings
I am trying to do some big bulk inserts to Postgres via node-postgres
When the bindings array exceeds 65536 values then passes to postgres the rest of values and when the query it runs I take the ...
0
votes
0answers
56 views
Not able to connect to PostgreSQL via NodeJS
Below is the connection details
exports.DB_NAME = "postgres";
exports.DB_USERNAME = "abcd";
exports.DB_PASSWORD = "abcd1234";
exports....
0
votes
1answer
73 views
(node) warning: possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
I am using pg node module for connecting database. I have been creating multiple connection for each DML operation. when continuous query execution takes place
I got warning message as "(node) ...
0
votes
0answers
21 views
Can I use node-postgres or sequelize with nginx?
Will there be any problem with the multiple instances that nginx might create of my webserver and the connection pool?
I'm asking because of this particular quote I found on sequelize documentation:
...
1
vote
3answers
34 views
(node-postgres, pg) Proper insertion of table name
How does one correctly provide the table name if the name can be dynamically determined and still prevent SQL injection attacks?
For example:
The following works but I believe is insecure:
dbclient....
0
votes
1answer
43 views
Postgres: Cannot connect from NodeJS (PG) with md5
Node v6.2 on Windows 10; PG (node-postgres) v4.4.2
Postgres 9.5 on Ubuntu 14.04 Trusty VirtualBox
I'm using the PG (node-postgres) module to connect to Postgres on Ubuntu in a virtual machine. I was ...
2
votes
1answer
41 views
How to get data that was createdAt or updatedAt 30 seconds from the the current time PostgreSQL
I'm trying to access data from a table that was created or updated data 30 seconds from the current time. Does anyone have any good idea of how to do this efficiently? I'm using node.js and pg package ...
0
votes
0answers
22 views
node+node-postgres+postgres insert into from select not working in trigger
I have a problem I do not understand.
I have a trigger on insert in one of my tables. This trigger is working perfectly if I insert the data in my table from the psql command line.
Now I normally do ...
1
vote
2answers
88 views
Omiting column names / inserting objects directly into node-postgres
I'd like to pass dictionaries with column names as keys, thus avoiding declaring the column names within the query itself (typing them directly).
Assume I have a table User with 2 column names:
...
0
votes
3answers
53 views
PostgreSQL lead() issue with camelCase column
So I'm trying to query a time card table whose structure is like this
employeeId | clockInTime| clockOutTime
-----------+------------+--------------
555 | 1462797450 | 1462785465
555 | ...
-1
votes
1answer
93 views
for loop inside query
I have this in mongo:
//fill QueryString
collection.find({"myID" : {$in:QueryString} },{}).toArray(function(err, Stuff) {
...
var flag = true;
for (var i=0; i<Stuff.length; i++) {
//if ...
0
votes
1answer
37 views
from mongo to postgresql - error: syntax error at or near “array_to_string”
I am trying to learn databases and nodejs.
I want to ask how can I translate the following from mongod to postgresql using nodejs.
//fill QueryString
collection.find({"myID" : {$in:QueryString} },{})...
0
votes
1answer
98 views
Node-Postgres: program does not work after 30 seconds while using Express, no problems without Express
I am using node-postgres to connect to a Postgres database from NodeJS; it gives a strange error Cannot read property 'rows' of undefined after running the program for 30 seconds (after the first ...
0
votes
1answer
49 views
out parameter result returns by node pg module - postgresql
I have created a procedure in postgresql as below.
CREATE OR REPLACE FUNCTION public.functiontest2(
IN data numeric,
OUT result numeric,
OUT result1 numeric)
RETURNS record AS
$BODY$
...
2
votes
2answers
200 views
Node calling postgres function with temp tables causing “memory leak”
I have a node.js program calling a Postgres (Amazon RDS micro instance) function, get_jobs within a transaction, 18 times a second using the node-postgres package by brianc.
The node code is just an ...
0
votes
0answers
36 views
How to print Postgresql schema via node-postgres or Knex.js
How to print Postgresql schema via node-postgres or Knex.js? Ideally, I would like to have a schema.sql that is generated by Knexjs migration like what Ruby's ActiveRecord does.
1
vote
2answers
125 views
postgres:get executable query from query with parameters
Is there any way to get executable query from query with $ parameters.Actually its weird but i want to store executable query in database.A complete query without parameters($1,$2,$3)
i am using node-...
1
vote
1answer
959 views
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 ...
0
votes
2answers
89 views
Postgresql: I can connect with the command line but not with node-postgres
When I use the CLI to connect to my database, everything works fine.
psql dbname postgres
psql ask me for the password I set before (with ALTER) and I get connected.
In my pg_hba.conf file I get ...
3
votes
2answers
71 views
Why does Node.js Postgres Wiki example insert multiple records per http request?
We are using the node-postgres (pg on NPM) for our app but were having issues so we decided to go back to the examples on the Wiki:
https://github.com/brianc/node-postgres/wiki/Example
When we ...
-1
votes
3answers
155 views
node-postgres : query not executing in sequence
i have kept insert & update code in 2 different files and based on condition
always insert should execute first and then update.but somehow update executes first then insert
test.js : ...
1
vote
1answer
19 views
Insert into table after pg dump
I used pg_dump to populate a table in new database. After that, I want to be able to insert rows into table using the default autoincrementer of the serial key. Here is what I have in table:
In this ...
1
vote
1answer
182 views
Parameterized query in Postgresql with a json array
I would like to invoke array_prepend into a json[] using a parameterized query. I am using pg-promise npm package but this uses the normal node-postgres adapter under the hood.
My query is:
db.query(...
3
votes
3answers
902 views
How do I properly insert multiple rows into PG with node-postgres?
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 out any ...
2
votes
1answer
248 views
Node-postgres Inserting a new record into my database does not return the new entry's data
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, ...
0
votes
1answer
51 views
Array of type enum coming back as string from Postgres
Given a custom enum:
CREATE TYPE vehicle AS ENUM ('car', 'truck', 'bicycle');
And a table like so:
CREATE TABLE vehicle_events (
timestamp timestamptz NOT NULL DEFAULT current_timestamp,
labels ...
2
votes
0answers
83 views
When should I call done() in node-postgres?
pg 4.4.3
I'm using socket.io to connect client-side to server. I've guessed, I suppose to connect server to database on server start, but there are a lot of warnings in pg "docs": 'use done() or bad ...
1
vote
0answers
155 views
This socket has been ended by the other party] code: 'EPIPE'
I'm receiving this error after some actions, for example, in ~10 seconds after successful insert:
Error: This socket has been ended by the other party] code: 'EPIPE'
Means, first time i'm ...
2
votes
1answer
218 views
Node function on AWS Lambda can't connect to database with node-pg
My function works locally, but, when I deploy to AWS Lambda, it can't seem to connect to my postgres database. Here's the error:
{ [Error: connect ECONNREFUSED] code: 'ECONNREFUSED', errno: '...
0
votes
2answers
56 views
From express + pg to reusable code : help refactoring
So, I have some node code to deal with and I’m hoping someone here can help me refactor it. This is express + pg:
app.get('/path', function (req, res, next) {
pg.connect(connectionString, function(...
1
vote
1answer
145 views
querying postgres db with node-postgres
Do I need to use pg.connect() every time I query the database? After looking over the githhub page and wiki, the examples show a query inside the pg.connect callback like this (the comments are from ...
0
votes
1answer
2k views
ECONNREFUSED when making GET request in app, but API returns JSON successfully
I'm writing a node app with React, using node-postgres and superagent for backend calls.
Let's say I'm making a GET request and using the JSON it returns to fill a table of students. My API looks like ...
2
votes
0answers
65 views
Node.js postgres UTF connect string
I'm using https://github.com/brianc/node-postgres pg module. Apparently I can't consume a Unicode password to connect to the db. From the same location psql with connection parameters goes OK. With ...
0
votes
2answers
274 views
prepared statements node-postgresql error with null result
i am new in node.js and postgresql. am allready connected with postgres db and execute some test code. after am going to use prepared statements.am create a sample login script. if user exist it ...
0
votes
1answer
94 views
Nodejs server disconnecting after idle for too long (ECONNRESET)
Good day,
I have the following issue:
my node.js server which is running node-postgres to communicate with a database gives the error read ECONNRESET when a client asks for it to query the database.
...
0
votes
1answer
41 views
Why is my query working on pgAdming but when I execute it from the server I get a query error (Error: Connection Terminated)?
I'm working on my Capstone project and it requires to store some telemetry data on a database. I'm using PostgreSQL 9.5 for the database and node for the server.
My problem is that when I try to ...
1
vote
2answers
229 views
Node-postgres: named parameters query (nodejs)
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 and ...
2
votes
2answers
127 views
Node/Express app— how to change connection string (node-postgress) based on localhost vs. remote server
I have a node application running an express server that is deployed on heroku. I'm using a postgres database (node-postgres) and currently have the application configured with a connection string for ...
0
votes
1answer
155 views
Node-postgres parameterized query for INSERT INTO if not exists
I have a working parameterized query for an insert statement but I now want to add in a 'WHERE NOT EXISTS' clause. The working insert looks like this:
pgClient.query("INSERT INTO social_posts (...
0
votes
1answer
29 views
Convert rows to lowercase in node-postgres
I'm currently using node-postgres to query my DB like so:
SELECT DISTINCT(name) FROM users.names ORDER BY name;
I want to return the lowercase of these names, so I've tried this:
SELECT DISTINCT(...
0
votes
1answer
52 views
Query unknown number of keywords in Postgres
I'm currently using postgres in node to query all users who have a certain tag associated with their account like so (note: I'm using node-postgres):
query = 'SELECT tags.*, pl.email FROM admin.tags ...
1
vote
1answer
397 views
node-postgres: done() - undefined is not a function
I am having a problem with my query function using node-postgres.
Selects, inserts and deletes all successfully perform the database query, but inserts and deletes trigger this error on the node ...
2
votes
1answer
83 views
large number of databases in postgres - architectural best practices
We are using postgres in a multi tenant nodejs set up. Each client has a separate database (and a separate node process). Connection pooling is implemented for each tenant using node-postgres module. ...