apla / node-clickhouse

Yandex ClickHouse driver for nodejs
MIT License
216 stars 50 forks source link

Basic Connection with clickhouse #2

Closed happyharry123 closed 5 years ago

happyharry123 commented 7 years ago

Hey apla, I have a trouble on connecting clickhouse with nodejs. I am now working with you sample code and some questions pop-up with the clickhouse options. I just want to know it is correct of the options format? Thank you a lot for this modules with clickhouse!

`var ClickHouse = require ('@apla/clickhouse'); var options = { host: '160.xx.xx.xxx:8123', auth:{ user:'abc123', password:'paswword123' }, }; var ch = new ClickHouse (options); var stream = ch.query ("SELECT * from xxx limit 1");

// or collect records yourself var rows = [];

stream.on ('metadata', function (columns) { // do something with column list }); ` I got an error about

first argument must be a string buffer arraybuffer array or array-like object

vickas777 commented 7 years ago

Think your auth is not correct. This config will help.

var options = {
  host: '160.xx.xx.xxx',
  port: 8123
  auth: 'abc123:paswword123',
  dataObjects:  'FORMAT JSON'
};
happyharry123 commented 7 years ago

Thank you Vickas. Your solution is correct, you save my day! Thank you.

nezed commented 5 years ago

Solved, probably must be fixed with #34