Skip to content

Commit 2110d74

Browse files
committed
Fix readme
1 parent 7780ec5 commit 2110d74

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

README.md

+33-10
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,44 @@
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
1645
npm run libchdb
1746
npm install
1847
npm run test
1948
```
20-
21-
### Examples
22-
23-
See [example.js](example.js).
24-
25-

0 commit comments

Comments
 (0)