node-postgres/test/integration/simple-query-tests.js

37 lines
911 B
JavaScript
Raw Normal View History

require(__dirname+"/test-helper");
2010-10-03 14:08:04 +08:00
//little helper to make a
//fresh client to the test DB
var makeClient = function() {
var client = new Client({
2010-10-03 14:08:04 +08:00
user: 'brian',
database: 'pgjstest'
});
client.on('Error', function(msg) {
console.log(msg);
});
return client;
2010-10-03 14:08:04 +08:00
};
2010-10-03 14:14:19 +08:00
var client3 = makeClient();
client3.connect();
client3.on('ReadyForQuery', function() {
console.log('client3 ready for query');
});
2010-10-11 07:23:06 +08:00
client3.query('create temporary table bang (id integer)');
client3.query('insert into bang(id) VALUES(1)');
var query = client3.query('select * from bang');
2010-10-11 12:02:50 +08:00
query.on('row', function(row) {
console.log(row);
2010-10-11 07:23:06 +08:00
});
query.on('end', function() {
client3.disconnect();
});
2010-10-03 14:14:19 +08:00
2010-10-03 13:45:10 +08:00
// client.query('create temporary table bang (id integer)');
// client.query('insert into bang(id) VALUES(1)');
// client.query('select * from bang',function(err, results, fields) {
// assert.equal(err, null);
// });