Node-postgres is a postgresql client module for node.js applications to interact with postgresql databases.
0
votes
0answers
6 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 ...
0
votes
0answers
7 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
22 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
16 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, ...
1
vote
1answer
23 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
55 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
39 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
45 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
0answers
34 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
28 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
58 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
49 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
61 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
16 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 ...
0
votes
1answer
41 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
117 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
52 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. ...
3
votes
2answers
86 views
Node-Postgres SELECT WHERE IN dynamic query optimization
We're working on a Node/Express web app with a Postgres database, using the node-postgres package. We followed the instructions in this question, and have our query working written this way:
...
1
vote
1answer
69 views
node-postgres: parameterised insert query cached, failing on 2nd run
I'm trying to run two parameterised insert queries using node-postgres: the first one specifies the primary key column, the second doesn't.
The second query, even though doesn't specify the primary ...
1
vote
1answer
24 views
Unable to fathom node-postgres error
Using node-postgres, the following snippet works fine:
let shift_solutions = function (ufrom, uto) {
let cmd = 'update solutions set "user" = \''+uto+'\' where "user" = \''+ufrom+'\''
...
-1
votes
1answer
31 views
how to load 2 related datasets together? (i.e posts and comments)
I'm fairly new to pg and trying to figure out what the best approach is to loading a set of posts and their associated comments together.
For example:
I'm trying to fetch a 10 posts and comments ...
0
votes
1answer
29 views
Is “raise exception” the only way to return an error from pgplsql to node-postgres?
Say, I have a pgplsql function (e.g. buyItem) which returns something (e.g. bought item parameters). In some cases I want to indicate that something went wrong so the result is empty (e.g. not enough ...
-1
votes
1answer
93 views
Node pg library auto commit vs explicit commit
I am using Node pg to connect and use my Postgres Database. I use Postgres functions from node js to insert update or fetch data. I also use connection pooling to get connections to the DB.
When ...
2
votes
1answer
129 views
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 ...
4
votes
2answers
2k views
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.
...
0
votes
1answer
22 views
First 'property' of node-postgres error object
Anybody know what the first pseudo-property is in my error object on a faulty query? When I console.log('' + error); it grabs the text within the brackets to display. Other than that, I'm not sure ...
0
votes
1answer
18 views
Is done() required if node-postgres .connect() returns with an error?
From the docs it sounds like err is not null if there was a problem getting a client from the pool. If that's the case, does it mean done() doesn't need to be called?
pg.connect(connString, ...
3
votes
0answers
245 views
Why can't I delete from db using node-postgres?
Is there something special i need to do with a parameterized query?
the following seems to succeed (i'm using a promise-ified client.query see end),
console.log('cancel for', data);
var ...
0
votes
1answer
34 views
node-postgres difference between done() and done(client)
Using node postgres what's the difference between done() and done(client).
According to the docs, if you are using a pool, done() just returns the connection to the pool for future reuse, and ...
0
votes
1answer
195 views
Postgres date using COPY from stream with node-postgres
I have the following table in PostgreSQL:
CREATE TABLE history (
request_date timestamp without time zone DEFAULT now() NOT NULL,
user_id uuid,
client_id character varying(255),
...
1
vote
2answers
83 views
How can I update multiple items from a select query in Postgres?
I'm using node.js, node-postgres and Postgres to put together a script to process quite a lot of data from a table. I'm using the cluster module as well, so I'm not stuck with a single thread.
I ...
0
votes
1answer
341 views
Returning nested JSON from many to many joined table from PostgreSQL to node.js
can anyone help me with querying many to many relation tables in postgres?
i have tables:
> 1.exercise(id,name)
> 2.tag(id,label)
> 3.tag_in_exercise(id,exercise_id,tag_id)
let say, that ...
6
votes
2answers
5k views
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:
<a href="#" ...
1
vote
1answer
400 views
Why does this bluebird pg code hang?
I'm trying to wrap my head around bluebird Promises, and going through some examples in the documentation. My current code is based on this example:
var Promise = require('bluebird');
var pg = ...
1
vote
0answers
458 views
node-postgres prepared statement - sql injection
I am new to node-postgres and am unable to resolve this error when I try to ensure no sql injection is possible with my prepared statement.
Here is a snippet of the code
// the prepared statement
...
0
votes
1answer
270 views
ExpressJS 4.0 exporting routes, getting TypeError
Any suggestions to solve the following error based on the code presented below would be would be appreciated, as I'm simply lost here:
~/public_html/server/routes/api.js:10
api.use(function(req, res, ...
1
vote
0answers
147 views
Memory problems using node_postgres connection pool
im fairly new to node.js and using node_postgres libray. I've been using sockjs and Primus
as transport for my web server prototype. I used PM2 as my monitoring tool on my server and noticed that the ...
0
votes
1answer
587 views
In NodeJS how to save JSON object as text with node-postgres module?
Finally i move forward from postgresql 9.1 to postresql 9.3 that supports JSON data type. Then the same code function properly.
However i think that what i want to do in the first place can be ...
4
votes
1answer
525 views
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
...
1
vote
2answers
575 views
Mass 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 ...
3
votes
2answers
2k views
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 ...
0
votes
1answer
56 views
Is it possible to get the SQL statement together with the error returned by node-postgres?
I get errors that look like this from node-postgres (when calling its client.query method):
{ [Error: syntax error at or near "as"]
severity: 'ERROR',
code: '42601',
position: '60',
file: ...
2
votes
1answer
364 views
Retrieving multiple rows with Sequelizejs
I am beginning to learn SequelizeJs however I encounter a small issue:
I have a model which is defined as such:
var ex_table= sequelize.define("ex_table", {
concept1: Sequelize.STRING(5),
...
0
votes
1answer
149 views
krakenjs and node postgres
How do I set up node-postgres using krakenjs? I want to take advantage of node-postgres's connection pooling which requires the client and done parameters. I guess I could set them using global ...
2
votes
2answers
3k views
Import sql file in node.js and execute against PostgreSQL
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 ...
11
votes
2answers
2k views
SSL for PostgreSQL connection nodejs
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;
...
3
votes
2answers
2k views
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 ...
1
vote
1answer
3k views
can not install node-postgres [closed]
I'm trying to setup node-postgres for my project. However I keep getting these gyp errors when I try to install it. How can I get node-postgres to recognize that my pg_config is located in ...
0
votes
0answers
82 views
Execute Statement using one value of query array
I am attempting to execute a query using a prepared array. The array has two elements but this query uses only one of them. I am using node-postgres.
Array:
var g=[];
g.push(email,password);
...
1
vote
1answer
218 views
NPM alias node-postgres to node-postgres-pure
I'm building a nodejs application that needs to run on a Windows server. I've managed to get almost everything working, but I've ran into a problem with the postgresql driver. BrianC has a pure ...