Skip to content

Commit

Permalink
Merge pull request #5 from chdb-io/session
Browse files Browse the repository at this point in the history
Fix session
  • Loading branch information
auxten committed Dec 30, 2023
2 parents 14b1198 + f1e7429 commit 782a8c1
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions example.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
const { query, Session } = require(".");

var result;
var ret;

// Test standalone query
result = query("SELECT version(), 'Hello chDB', chdb()", "CSV");
console.log("Standalone Query Result:", result);
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");
result = session.query("SELECT 123", "CSV")
console.log("Session Query Result:", result);
result = session.query("CREATE DATABASE IF NOT EXISTS testdb;" +
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);")

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

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

// Clean up the session
session.cleanup();

0 comments on commit 782a8c1

Please sign in to comment.