Merge branch 'master' of ssh://github.com/brianc/node-pg-copy-streams
This commit is contained in:
commit
2af7ce57b1
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
|
||||
|
||||
```js
|
||||
var pg = require('pg');
|
||||
var {Pool} = require('pg');
|
||||
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'));
|
||||
stream.pipe(process.stdout);
|
||||
stream.on('end', done);
|
||||
@ -35,10 +37,12 @@ pg.connect(function(err, client, done) {
|
||||
|
||||
```js
|
||||
var fs = require('fs');
|
||||
var pg = require('pg');
|
||||
var {Pool} = require('pg');
|
||||
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 fileStream = fs.createReadStream('some_file.tsv')
|
||||
fileStream.on('error', done);
|
||||
|
Loading…
Reference in New Issue
Block a user