| 
1 | 1 | <img src="https://avatars.githubusercontent.com/u/132536224" width=130 />  | 
2 | 2 | 
 
  | 
3 | 3 | [](https://github.com/chdb-io/chdb-node/actions/workflows/chdb-node-test.yml)  | 
 | 4 | +[](https://badge.fury.io/js/chdb)  | 
4 | 5 | 
 
  | 
5 | 6 | # chdb-node  | 
6 |  | -[chDB](https://github.com/chdb-io/chdb) nodejs bindings for fun and hacking.  | 
 | 7 | +[chDB](https://github.com/chdb-io/chdb) nodejs bindings.  | 
7 | 8 | 
 
  | 
8 |  | -### Status  | 
 | 9 | +### Install  | 
9 | 10 | 
 
  | 
10 |  | -- Experimental bindings  | 
11 |  | -- Requires [`libchdb`](https://github.com/chdb-io/chdb) on the system  | 
 | 11 | +```bash  | 
 | 12 | +npm i chdb  | 
 | 13 | +```  | 
 | 14 | + | 
 | 15 | +### Usage  | 
 | 16 | + | 
 | 17 | +```javascript  | 
 | 18 | +const { query, Session } = require("chdb");  | 
 | 19 | + | 
 | 20 | +var ret;  | 
 | 21 | + | 
 | 22 | +// Test standalone query  | 
 | 23 | +ret = query("SELECT version(), 'Hello chDB', chdb()", "CSV");  | 
 | 24 | +console.log("Standalone Query Result:", ret);  | 
 | 25 | + | 
 | 26 | +// Test session query  | 
 | 27 | +// Create a new session instance  | 
 | 28 | +const session = new Session("./chdb-node-tmp");  | 
 | 29 | +ret = session.query("SELECT 123", "CSV")  | 
 | 30 | +console.log("Session Query Result:", ret);  | 
 | 31 | +ret = session.query("CREATE DATABASE IF NOT EXISTS testdb;" +  | 
 | 32 | +    "CREATE TABLE IF NOT EXISTS testdb.testtable (id UInt32) ENGINE = MergeTree() ORDER BY id;");  | 
 | 33 | + | 
 | 34 | +session.query("USE testdb; INSERT INTO testtable VALUES (1), (2), (3);")  | 
12 | 35 | 
 
  | 
13 |  | -### Build  | 
 | 36 | +ret = session.query("SELECT * FROM testtable;")  | 
 | 37 | +console.log("Session Query Result:", ret);  | 
 | 38 | + | 
 | 39 | +// Clean up the session  | 
 | 40 | +session.cleanup();  | 
 | 41 | + | 
 | 42 | +```  | 
 | 43 | + | 
 | 44 | +#### Build from source  | 
14 | 45 | 
 
  | 
15 | 46 | ```bash  | 
16 | 47 | npm run libchdb  | 
17 | 48 | npm install  | 
18 | 49 | npm run test  | 
19 | 50 | ```  | 
20 |  | - | 
21 |  | -### Examples  | 
22 |  | - | 
23 |  | -See [example.js](example.js).  | 
24 |  | - | 
25 |  | - | 
 | 
0 commit comments