Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No examples work #9

Open
Mickael-van-der-Beek opened this issue Feb 22, 2024 · 3 comments
Open

No examples work #9

Mickael-van-der-Beek opened this issue Feb 22, 2024 · 3 comments

Comments

@Mickael-van-der-Beek
Copy link

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
Copy link

Seeing the same issue, also on Apple Silicone

@sergeysolovev
Copy link

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
Copy link
Member

auxten commented Jun 12, 2024

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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants