Skip to content

Commit 4afe053

Browse files
authored
Update README.md
1 parent 28f1c01 commit 4afe053

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

README.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img src="https://avatars.githubusercontent.com/u/132536224" width=130 />
33
</a>
44

5-
[![chDB-node](https://github.com/metrico/chdb-bun/actions/workflows/bun-test.yml/badge.svg)](https://github.com/metrico/chdb-bun/actions/workflows/bun-test.yml)
5+
[![chDB-bun](https://github.com/metrico/chdb-bun/actions/workflows/bun-test.yml/badge.svg)](https://github.com/metrico/chdb-bun/actions/workflows/bun-test.yml)
66

77
# chdb-bun <img src="https://user-images.githubusercontent.com/1423657/236928733-43e4f74e-5cff-4b3f-8bb7-20df58e10829.png" height=20 />
88
Experimental [chDB](https://github.com/auxten/chdb) FFI bindings for [bun.sh](https://bun.sh)
@@ -18,18 +18,44 @@ bun install chdb-bun
1818
```
1919

2020
#### Usage
21+
22+
#### Query Constructor
2123
```js
22-
import { db, chdb } from 'chdb-bun';
24+
import { db } from 'chdb-bun';
2325

2426
const conn = new db('CSV')
25-
var result;
27+
console.log(conn.query("SELECT version()"));
28+
```
2629

27-
// Test query
28-
result = conn.query("SELECT version()");
29-
console.log(result)
30+
#### Query _(query, *format)_
31+
```javascript
32+
import { db } from 'chdb-bun';
33+
const conn = new db('CSV')
34+
35+
// Query (ephemeral)
36+
var result = conn.query("SELECT version()", "CSV");
37+
console.log(result) // 23.10.1.1
38+
```
39+
40+
#### Session _(query, *format, *path)_
41+
```javascript
42+
import { db } from 'chdb-bun';
43+
const conn = new db('CSV', '/tmp')
3044

31-
// Test session
45+
// Query Session (persistent)
3246
conn.session("CREATE FUNCTION IF NOT EXISTS hello AS () -> 'chDB'");
3347
result = conn.session("SELECT hello()", "CSV");
3448
console.log(result)
3549
```
50+
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+
conn.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+
61+
<br>

0 commit comments

Comments
 (0)