brianc/node-pg-query-stream

Issue when using Pool

bwheel181 opened this issue · 0 comments

const { Pool } = require('pg');
const QueryStream = require('pg-query-stream');
const config = require('config');

const pool = new Pool({
  host: config.redshift.host,
  database: config.redshift.database,
  user: config.redshift.user,
  password: config.redshift.password,
  port: 5439,
});

const getReportDataAsync = (queryString, onNewRow, done) => {
  pool.connect((err, client, release) => {
    if (err) throw err;
    const query = new QueryStream(queryString);
    const stream = client.query(query);
    stream.on('end', release);
    stream.pipe(process.stdout);
  });
};

module.exports = { getReportDataAsync };

This seems to break on even simple queries. Look like the pool isn't allowing the same abilities as a client connection? I've used a lot of ctrl + z here. Anything I can do to help?