|
1 |
| -<a href="https://chdb.fly.dev" target="_blank"> |
2 |
| - <img src="https://avatars.githubusercontent.com/u/132536224" width=130 /> |
3 |
| -</a> |
| 1 | +<img src="https://avatars.githubusercontent.com/u/132536224" width=130 /> |
4 | 2 |
|
5 | 3 | [](https://github.com/chdb-io/chdb-node/actions/workflows/chdb-node-test.yml)
|
6 | 4 |
|
|
9 | 7 |
|
10 | 8 | ### Status
|
11 | 9 |
|
12 |
| -- experimental, unstable, subject to changes |
13 |
| -- requires [`libchdb`](https://github.com/chdb-io/chdb) on the system |
14 |
| -- :wave: _C/Node developer? Jump in and help us evolve this prototype into a stable module!_ |
| 10 | +- Experimental bindings |
| 11 | +- Requires [`libchdb`](https://github.com/chdb-io/chdb) on the system |
15 | 12 |
|
16 |
| -<br> |
| 13 | +### Build |
17 | 14 |
|
18 |
| -### Examples |
19 |
| - |
20 |
| -#### Query Constructor |
21 |
| -```javascript |
22 |
| -const chdb = require("chdb-node"); |
23 |
| - |
24 |
| -// Query (ephemeral) |
25 |
| -const db = new chdb.db("CSV") // format |
26 |
| -var result = db.query("SELECT version()"); |
27 |
| -console.log(result) // 23.10.1.1 |
28 |
| - |
29 |
| -// Query Session (persistent) |
30 |
| -const dbdisk = new chdb.db("CSV", "/tmp/mysession") // format, storage path |
31 |
| -dbdisk.session("CREATE FUNCTION IF NOT EXISTS hello AS () -> 'chDB'"); |
32 |
| -var result = dbdisk.session("SELECT hello()", "TabSeparated"); // optional format override |
33 |
| -console.log(result) // chDB |
| 15 | +```bash |
| 16 | +npm run libchdb |
| 17 | +npm install |
| 18 | +npm build |
| 19 | +npm run test |
34 | 20 | ```
|
35 | 21 |
|
36 |
| -#### Query _(query, format)_ |
37 |
| -```javascript |
38 |
| -const chdb = require("chdb-node").chdb; |
39 |
| -var result = chdb.Execute("SELECT version()", "CSV"); |
40 |
| -console.log(result) // 23.10.1.1 |
41 |
| -``` |
| 22 | +### Examples |
42 | 23 |
|
43 |
| -#### Session _(query, *format, *path)_ |
44 |
| -```javascript |
45 |
| -const chdb = require("chdb-node").chdb; |
46 |
| -chdb.Session("CREATE FUNCTION IF NOT EXISTS hello AS () -> 'chDB'") |
47 |
| -var result = = chdb.Session("SELECT hello();") |
48 |
| -console.log(result) // chDB |
49 |
| -``` |
| 24 | +See [example.js](example.js). |
50 | 25 |
|
51 |
| -> ⚠️ Sessions persist table data to disk. You can specify `path` to implement auto-cleanup strategies: |
52 |
| -```javascript |
53 |
| -const temperment = require("temperment"); |
54 |
| -const tmp = temperment.directory(); |
55 |
| -chdb.Session("CREATE FUNCTION IF NOT EXISTS hello AS () -> 'chDB'", "CSV", tmp) |
56 |
| -var result = = chdb.Session("SELECT hello();") |
57 |
| -console.log(result) // chDB |
58 |
| -tmp.cleanup.sync(); |
59 |
| -``` |
60 | 26 |
|
61 |
| -<br> |
0 commit comments