-
-
Notifications
You must be signed in to change notification settings - Fork 3
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 #5 from chdb-io/session
Fix session
- Loading branch information
Showing
1 changed file
with
8 additions
and
9 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,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(); |