Socket
Socket
Sign inDemoInstall

@prxm/clickhouse

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prxm/clickhouse


Version published
Weekly downloads
6
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

@prxm/clickhouse : A dead simple Clickhouse client

Installation

npm install @prxm/clickhouse

Usage

const clickhouse = require('@prxm/clickhouse');
const config = {
  host: 'localhost',
  protocol: 'http',
  user: 'default',
  password: 'password',
};
const client = clickhouse(config);

(async () => {
  await client.open();
  const res = await client.selectJson('SELECT number FROM system.numbers LIMIT 10;');
  console.log(res);
  await client.close();
})();

API

The clickhouse client exposes several internal methods for usage

client.query(query, ?[params], ?queryId): Promise

Send an async query to the HTTP interface.

query: string

SQL query statement.

const res = await client.query(`SELECT * FROM foo WHERE a=? AND b=?`, ['hello', 'world']);
console.log(res.data, res.meta);
params: sqlstring params

Used for passing params to the query as

client.query(`SELECT * FROM foo WHERE a=? AND b=?`, ['hello', 'world']);
queryId: string

Used as a unique queryId for the query.

client.query(`SELECT * FROM foo;`, [], 'xxx');

client.selectJson(query, [params], ?queryId): Promise<JSON>

Sends an async JSON query to the HTTP interface.

query: string

SQL query statement.

params: sqlstring params

Used for passing params to the query as

client.selectJson(`SELECT * FROM foo WHERE a=? AND b=?`, ['hello', 'world']);
queryId: string

Used as a unique queryId for the query.

client.selectJson(`SELECT * FROM foo;`, [], 'xxx');

client.insertBatch({table, items}, ?queryId): Promise

Batch instert for tables.

{table: string}

The table's name.

{items: [{}]}

The items to insert, keys are used as the corresponding column names.

const items = [
  {a: 1, b: 'foo', c: 3},
  {a: 1, b: 'baz', c: 3},
];
client.insertBatch({ table: 'batch',items});
queryId: string

Used as a unique queryId for the query.

client.insertBatch({ table: 'batch',items}, 'xxx')

FAQs

Package last updated on 20 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc