2014-12-12 16:23:09 +08:00
|
|
|
var helper = require('../test-helper');
|
|
|
|
var assert = require('assert');
|
|
|
|
var copyFrom = require('pg-copy-streams').from;
|
|
|
|
|
2014-12-14 01:25:07 +08:00
|
|
|
if(helper.args.native) return;
|
2014-12-12 16:23:09 +08:00
|
|
|
|
2015-12-04 23:28:01 +08:00
|
|
|
helper.pg.connect(helper.config, function (err, client, done) {
|
2014-12-12 16:23:09 +08:00
|
|
|
if (err) throw err;
|
|
|
|
|
|
|
|
var c = 'CREATE TEMP TABLE employee (id integer, fname varchar(400), lname varchar(400))';
|
|
|
|
|
|
|
|
client.query(c, function (err) {
|
|
|
|
if (err) throw err;
|
|
|
|
|
2014-12-14 01:25:07 +08:00
|
|
|
var stream = client.query(copyFrom("COPY employee FROM STDIN"));
|
2014-12-12 16:23:09 +08:00
|
|
|
stream.on('end', function () {
|
|
|
|
done();
|
|
|
|
helper.pg.end();
|
|
|
|
});
|
|
|
|
|
|
|
|
for (var i = 1; i <= 5; i++) {
|
|
|
|
var line = ['1\ttest', i, '\tuser', i, '\n'];
|
|
|
|
stream.write(line.join(''));
|
|
|
|
}
|
|
|
|
stream.end();
|
|
|
|
});
|
|
|
|
});
|