Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
@clickhouse/client
Advanced tools
@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.
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();
The 'clickhouse' npm package is another client for interacting with ClickHouse databases. It offers similar functionalities such as querying and inserting data, but may have different API conventions and additional features.
The 'node-clickhouse' npm package is a client for ClickHouse that supports both HTTP and native protocols. It offers comprehensive functionalities for interacting with ClickHouse databases, including querying, inserting, and managing schemas.
Official Node.js client for ClickHouse, written purely in TypeScript, thoroughly tested with actual ClickHouse versions.
It is focused on data streaming for both inserts and selects using standard Node.js Streaming API.
See the ClickHouse website for the full documentation entry.
You can find code samples in the examples folder (with README).
Check out our contributing guide.
0.0.15
FAQs
Official JS client for ClickHouse DB - Node.js implementation
The npm package @clickhouse/client receives a total of 597,136 weekly downloads. As such, @clickhouse/client popularity was classified as popular.
We found that @clickhouse/client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.