我遇到错误 查询Clickhouse数据库时出现错误。
const { ClickHouse } = require('clickhouse');
const clickhouse = new ClickHouse({
debug: false,
basicAuth: {
username: 'username',
password: 'password',
},
});
clickhouse.query('SHOW DATABASES;').exec((err, rows) => {
console.log(err);
console.log(rows);
})
-> ====输出=====
[nodemon]起始节点index.js 错误:getaddrinfo ENOTFOUND http 在GetAddrInfoReqWrap.onlookup [as oncomplete](dns.js:60:26){ errno:“ ENOTFOUND”, 代码:“ ENOTFOUND”, syscall:“ getaddrinfo”, 主机名:“ http” } 未定义
答案 0 :(得分:1)
您应指定托管Clickhouse的主机和端口
const { ClickHouse } = require('clickhouse');
const clickhouse = new ClickHouse(url: process.env.DATABASE_HOST,
port: parseInt(process.env.DATABASE_PORT),
debug: false,
basicAuth: {
username: "username",
password: "password"
},
isUseGzip: false,
config: {
session_timeout: 60,
output_format_json_quote_64bit_integers: 0,
enable_http_compression: 0
});
clickhouse.query('SHOW DATABASES;').exec((err, rows) => {
console.log(err);
console.log(rows);
})