-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from chdb-io/mac_loader_path
Fix macOS loader path
- Loading branch information
Showing
5 changed files
with
52 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,50 @@ | ||
<img src="https://avatars.githubusercontent.com/u/132536224" width=130 /> | ||
|
||
[](https://github.com/chdb-io/chdb-node/actions/workflows/chdb-node-test.yml) | ||
[](https://badge.fury.io/js/chdb) | ||
|
||
# chdb-node | ||
[chDB](https://github.com/chdb-io/chdb) nodejs bindings for fun and hacking. | ||
[chDB](https://github.com/chdb-io/chdb) nodejs bindings. | ||
|
||
### Status | ||
### Install | ||
|
||
- Experimental bindings | ||
- Requires [`libchdb`](https://github.com/chdb-io/chdb) on the system | ||
```bash | ||
npm i chdb | ||
``` | ||
|
||
### Usage | ||
|
||
```javascript | ||
const { query, Session } = require("chdb"); | ||
|
||
var ret; | ||
|
||
// Test standalone query | ||
ret = query("SELECT version(), 'Hello chDB', chdb()", "CSV"); | ||
console.log("Standalone Query Result:", ret); | ||
|
||
// Test session query | ||
// Create a new session instance | ||
const session = new Session("./chdb-node-tmp"); | ||
ret = session.query("SELECT 123", "CSV") | ||
console.log("Session Query Result:", ret); | ||
ret = session.query("CREATE DATABASE IF NOT EXISTS testdb;" + | ||
"CREATE TABLE IF NOT EXISTS testdb.testtable (id UInt32) ENGINE = MergeTree() ORDER BY id;"); | ||
|
||
session.query("USE testdb; INSERT INTO testtable VALUES (1), (2), (3);") | ||
|
||
### Build | ||
ret = session.query("SELECT * FROM testtable;") | ||
console.log("Session Query Result:", ret); | ||
|
||
// Clean up the session | ||
session.cleanup(); | ||
|
||
``` | ||
|
||
#### Build from source | ||
|
||
```bash | ||
npm run libchdb | ||
npm install | ||
npm run test | ||
``` | ||
|
||
### Examples | ||
|
||
See [example.js](example.js). | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
cd "$(dirname "$0")" | ||
|
||
if [[ $(uname -s) == "Darwin" ]]; then | ||
install_name_tool -change libchdb.so @loader_path/../../libchdb.so build/Release/chdb_node.node | ||
otool -L build/Release/chdb_node.node | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters