|
19 | 19 |
|
20 | 20 | #### Query Constructor |
21 | 21 | ```javascript |
22 | | -const chdb = require('chdb-node'); |
| 22 | +const chdb = require("chdb-node"); |
23 | 23 | var result; |
24 | 24 |
|
25 | 25 | // Query (ephemeral) |
26 | | -const db = new chdb.db('CSV') // format |
| 26 | +const db = new chdb.db("CSV") // format |
27 | 27 | result = db.query("SELECT version()"); |
28 | 28 | console.log(result) |
29 | 29 |
|
30 | 30 | // Query Session (persistent) |
31 | | -const dbdisk = new chdb.db('CSV', '/tmp/mysession') // format, storage path |
| 31 | +const dbdisk = new chdb.db("CSV", "/tmp/mysession") // format, storage path |
32 | 32 | dbdisk.session("CREATE FUNCTION IF NOT EXISTS hello AS () -> 'chDB'"); |
33 | 33 | result = dbdisk.session("SELECT hello()", "TabSeparated"); // optional format override |
34 | 34 | console.log(result) |
35 | 35 | ``` |
36 | 36 |
|
37 | 37 | #### Query _(query, format)_ |
38 | 38 | ```javascript |
39 | | -const chdb = require('chdb-node').chdb; |
40 | | -var result = chdb.Execute('SELECT version()', 'CSV'); |
| 39 | +const chdb = require("chdb-node").chdb; |
| 40 | +var result = chdb.Execute("SELECT version()", "CSV"); |
41 | 41 | console.log(result) // 23.6.1.1 |
42 | 42 | ``` |
43 | 43 |
|
44 | 44 | #### Session _(query, *format, *path)_ |
45 | 45 | ```javascript |
46 | | -const chdb = require('chdb-node').chdb; |
| 46 | +const chdb = require("chdb-node").chdb; |
47 | 47 | chdb.Session("CREATE FUNCTION IF NOT EXISTS hello AS () -> 'chDB'") |
48 | 48 | var result = = chdb.Session("SELECT hello();") |
49 | 49 | console.log(result) // chDB |
50 | 50 | ``` |
51 | 51 |
|
52 | 52 | > ⚠️ Sessions persist table data to disk. You can specify `path` to implement auto-cleanup strategies: |
53 | 53 | ```javascript |
54 | | -const temperment = require('temperment'); |
| 54 | +const temperment = require("temperment"); |
55 | 55 | const tmp = temperment.directory(); |
56 | 56 | chdb.Session("CREATE FUNCTION IF NOT EXISTS hello AS () -> 'chDB'", "CSV", tmp) |
57 | 57 | var result = = chdb.Session("SELECT hello();") |
|
0 commit comments