返回集成

Node.js

core

安装

npm i @clickhouse/client

示例

创建实例

import { createClient } from '@clickhouse/client'

const client = createClient({
  host: `https://<host>:8443`,
  password: '<password>',
})

简单的 'command' 命令,无结果返回

await client.exec({
  query: `
    CREATE TABLE IF NOT EXISTS clickhouse_js_example_table
    (id UInt64, name String)
    ORDER BY (id)
  `,
  clickhouse_settings: {
    wait_end_of_query: 1,
  },
})

批量插入

await client.insert({
  table: 'clickhouse_js_example_table',
  values: [
    { id: 42, name: 'foo' },
    { id: 42, name: 'bar' },
  ],
  format: 'JSONEachRow',
})

基本查询

const rows = await client.query({
  query: 'SELECT * FROM clickhouse_js_example_table',
  format: 'JSONEachRow',
})

console.log(await rows.json())

其他集成

开始使用 ClickHouse 免费

我们将为您提供 30 天试用期和 300 美元信用额度,供您自行支配。
©2025ClickHouse, Inc. 总部位于加利福尼亚州湾区和荷兰阿姆斯特丹。