File tree 1 file changed +33
-10
lines changed
1 file changed +33
-10
lines changed Original file line number Diff line number Diff line change 5
5
# chdb-node
6
6
[ chDB] ( https://github.com/chdb-io/chdb ) nodejs bindings for fun and hacking.
7
7
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);" )
9
33
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);
12
36
13
- ### Build
37
+ // Clean up the session
38
+ session .cleanup ();
39
+
40
+ ```
41
+
42
+ #### Build from source
14
43
15
44
``` bash
16
45
npm run libchdb
17
46
npm install
18
47
npm run test
19
48
```
20
-
21
- ### Examples
22
-
23
- See [ example.js] ( example.js ) .
24
-
25
-
You can’t perform that action at this time.
0 commit comments