Update to be pq 7.0 compilant
pg singletons are no longer supported according to https://node-postgres.com/guides/upgrading , updated example to reflect upgrade changes.
This commit is contained in:
parent
e15feb199a
commit
455e170084
12
README.md
12
README.md
@ -20,10 +20,12 @@ If you're not familiar with the feature (I wasn't either) you can read this for
|
|||||||
### pipe from a table to stdout
|
### pipe from a table to stdout
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var pg = require('pg');
|
var {Pool} = require('pg');
|
||||||
var copyTo = require('pg-copy-streams').to;
|
var copyTo = require('pg-copy-streams').to;
|
||||||
|
|
||||||
pg.connect(function(err, client, done) {
|
var pool = new Pool();
|
||||||
|
|
||||||
|
pool.connect(function(err, client, done) {
|
||||||
var stream = client.query(copyTo('COPY my_table TO STDOUT'));
|
var stream = client.query(copyTo('COPY my_table TO STDOUT'));
|
||||||
stream.pipe(process.stdout);
|
stream.pipe(process.stdout);
|
||||||
stream.on('end', done);
|
stream.on('end', done);
|
||||||
@ -35,10 +37,12 @@ pg.connect(function(err, client, done) {
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var pg = require('pg');
|
var {Pool} = require('pg');
|
||||||
var copyFrom = require('pg-copy-streams').from;
|
var copyFrom = require('pg-copy-streams').from;
|
||||||
|
|
||||||
pg.connect(function(err, client, done) {
|
var pool = new Pool();
|
||||||
|
|
||||||
|
pool.connect(function(err, client, done) {
|
||||||
var stream = client.query(copyFrom('COPY my_table FROM STDIN'));
|
var stream = client.query(copyFrom('COPY my_table FROM STDIN'));
|
||||||
var fileStream = fs.createReadStream('some_file.tsv')
|
var fileStream = fs.createReadStream('some_file.tsv')
|
||||||
fileStream.on('error', done);
|
fileStream.on('error', done);
|
||||||
|
Loading…
Reference in New Issue
Block a user