Socket
Socket
Sign inDemoInstall

@clickhouse/client

Package Overview
Dependencies
Maintainers
3
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clickhouse/client

Official JS client for ClickHouse DB


Version published
Weekly downloads
604K
decreased by-25.12%
Maintainers
3
Weekly downloads
 
Created

What is @clickhouse/client?

@clickhouse/client is an npm package that provides a client for interacting with ClickHouse, a columnar database management system. It allows you to perform various database operations such as querying, inserting data, and managing database schemas.

What are @clickhouse/client's main functionalities?

Querying Data

This feature allows you to execute SQL queries against a ClickHouse database. The code sample demonstrates how to create a client instance and perform a SELECT query.

const { ClickHouse } = require('@clickhouse/client');

const client = new ClickHouse({
  url: 'http://localhost:8123',
  basicAuth: {
    username: 'default',
    password: '',
  },
});

async function queryData() {
  const rows = await client.query('SELECT * FROM my_table').toPromise();
  console.log(rows);
}

queryData();

Inserting Data

This feature allows you to insert data into a ClickHouse table. The code sample demonstrates how to create a client instance and perform an INSERT operation.

const { ClickHouse } = require('@clickhouse/client');

const client = new ClickHouse({
  url: 'http://localhost:8123',
  basicAuth: {
    username: 'default',
    password: '',
  },
});

async function insertData() {
  const result = await client.insert('INSERT INTO my_table (column1, column2) VALUES', [
    [1, 'value1'],
    [2, 'value2'],
  ]).toPromise();
  console.log(result);
}

insertData();

Managing Database Schemas

This feature allows you to manage database schemas, such as creating or altering tables. The code sample demonstrates how to create a new table in a ClickHouse database.

const { ClickHouse } = require('@clickhouse/client');

const client = new ClickHouse({
  url: 'http://localhost:8123',
  basicAuth: {
    username: 'default',
    password: '',
  },
});

async function createTable() {
  const result = await client.query(`
    CREATE TABLE IF NOT EXISTS my_table (
      id UInt32,
      name String
    ) ENGINE = MergeTree()
    ORDER BY id
  `).toPromise();
  console.log(result);
}

createTable();

Other packages similar to @clickhouse/client

Keywords

FAQs

Package last updated on 14 Mar 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