https://github.com/chdb-io/chdb-node
Native NodeJS bindings for chDB, an in-process SQL OLAP Engine powered by ClickHouse
https://github.com/chdb-io/chdb-node
chdb clickhouse ffi napi nodejs olap
Last synced: about 1 month ago
JSON representation
Native NodeJS bindings for chDB, an in-process SQL OLAP Engine powered by ClickHouse
- Host: GitHub
- URL: https://github.com/chdb-io/chdb-node
- Owner: chdb-io
- License: apache-2.0
- Created: 2023-05-08T13:16:52.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-19T13:35:46.000Z (3 months ago)
- Last Synced: 2025-05-07T18:08:14.054Z (about 1 month ago)
- Topics: chdb, clickhouse, ffi, napi, nodejs, olap
- Language: C++
- Homepage: https://chdb.io
- Size: 348 KB
- Stars: 36
- Watchers: 5
- Forks: 5
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-repositories - chdb-io/chdb-node - Native NodeJS bindings for chDB, an in-process SQL OLAP Engine powered by ClickHouse (C++)
README
[](https://badge.fury.io/js/chdb)
# chdb-node
[chDB](https://github.com/chdb-io/chdb) nodejs bindings.### Install
```bash
npm i chdb
```### Usage
```javascript
const { query, Session } = require("chdb");var ret;
// Test standalone query
ret = query("SELECT version(), 'Hello chDB', chdb()", "CSV");
console.log("Standalone Query Result:", ret);// Test session query
// Create a new session instance
const session = new Session("./chdb-node-tmp");
ret = session.query("SELECT 123", "CSV")
console.log("Session Query Result:", ret);
ret = session.query("CREATE DATABASE IF NOT EXISTS testdb;" +
"CREATE TABLE IF NOT EXISTS testdb.testtable (id UInt32) ENGINE = MergeTree() ORDER BY id;");session.query("USE testdb; INSERT INTO testtable VALUES (1), (2), (3);")
ret = session.query("SELECT * FROM testtable;")
console.log("Session Query Result:", ret);// If an error occurs, it will be thrown
try {
session.query("SELECT * FROM non_existent_table;", "CSV");
}
catch (e) {
console.log("Error:", e.message);
}// Clean up the session
session.cleanup();```
#### Build from source
```bash
npm run libchdb
npm install
npm run test
```