File tree Expand file tree Collapse file tree 1 file changed +33
-10
lines changed Expand file tree Collapse file tree 1 file changed +33
-10
lines changed Original file line number Diff line number Diff line change 55# chdb-node
66[ chDB] ( https://github.com/chdb-io/chdb ) nodejs bindings for fun and hacking.
77
8- ### Status
8+ ### Install
9+ ``` bash
10+ npm i chdb
11+ ```
12+
13+ ### Usage
14+
15+ ``` javascript
16+ const { query , Session } = require (" chdb" );
17+
18+ var ret;
19+
20+ // Test standalone query
21+ ret = query (" SELECT version(), 'Hello chDB', chdb()" , " CSV" );
22+ console .log (" Standalone Query Result:" , ret);
23+
24+ // Test session query
25+ // Create a new session instance
26+ const session = new Session (" ./chdb-node-tmp" );
27+ ret = session .query (" SELECT 123" , " CSV" )
28+ console .log (" Session Query Result:" , ret);
29+ ret = session .query (" CREATE DATABASE IF NOT EXISTS testdb;" +
30+ " CREATE TABLE IF NOT EXISTS testdb.testtable (id UInt32) ENGINE = MergeTree() ORDER BY id;" );
31+
32+ session .query (" USE testdb; INSERT INTO testtable VALUES (1), (2), (3);" )
933
10- - Experimental bindings
11- - Requires [ ` libchdb ` ] ( https://github.com/chdb-io/chdb ) on the system
34+ ret = session . query ( " SELECT * FROM testtable; " )
35+ console . log ( " Session Query Result: " , ret);
1236
13- ### Build
37+ // Clean up the session
38+ session .cleanup ();
39+
40+ ```
41+
42+ #### Build from source
1443
1544``` bash
1645npm run libchdb
1746npm install
1847npm run test
1948```
20-
21- ### Examples
22-
23- See [ example.js] ( example.js ) .
24-
25-
You can’t perform that action at this time.
0 commit comments