chdb-io / chdb-node

Native NodeJS bindings for chDB, an in-process SQL OLAP Engine powered by ClickHouse
https://chdb.io
Apache License 2.0
32 stars 3 forks source link

No examples work #9

Closed Mickael-van-der-Beek closed 2 months ago

Mickael-van-der-Beek commented 9 months ago

This is quite a simple issue, none of the examples in the README file work:

Example n°1:

const { query } = require("chdb");
const ret = query("SELECT version(), 'Hello chDB', chdb()", "CSV");

Will produce the following error: Uncaught Error: Error in native callback.

Example n°2:

const { Session } = require("chdb");
const session = new Session("./chdb-node-tmp");
const ret = session.query("SELECT 123", "CSV")

Will make ret have the value '' (empty string).

Here's my environment:

OS: Mac OSX Ventura 13.2.1 Architecture: M1 Apple Silicone Package Version: 1.1.2 Node.js Version: v18.4.0

blake-mealey commented 9 months ago

Seeing the same issue, also on Apple Silicone

sergeysolovev commented 7 months ago

Confirm the same issue, reproduces on macos (arm) and linux, Node.js v20.10.0, libchdb installed

/Users/sergees/repos/deno_chdb/node_modules/chdb/index.js:12
  return chdbNode.Query(query, format);
auxten commented 5 months ago

It works now on my macOS M1:

~/Codes/go/src/github.com/auxten/node-play ll
total 24
-rw-r--r--  1 auxten  staff   751B Jun 12 11:13 e1.js
drwxr-xr-x  7 auxten  staff   224B Jun 12 11:11 node_modules
-rw-r--r--  1 auxten  staff   2.1K Jun 12 11:11 package-lock.json
-rw-r--r--  1 auxten  staff    49B Jun 12 11:11 package.json
~/Codes/go/src/github.com/auxten/node-play node e1.js 
Standalone Query Result: "23.10.1.1","Hello chDB","1.1.0"

Session Query Result: 123

Session Query Result: 1
2
3

~/Codes/go/src/github.com/auxten/node-play cat e1.js     
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);")

ret = session.query("SELECT * FROM testtable;")
console.log("Session Query Result:", ret);

// Clean up the session
session.cleanup();
auxten commented 3 months ago

Please try again, I think it should be fixed on v1.2.0