-
Notifications
You must be signed in to change notification settings - Fork 30
/
session_level_commands.ts
36 lines (30 loc) · 1.04 KB
/
session_level_commands.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { createClient } from '@clickhouse/client' // or '@clickhouse/client-web'
import * as crypto from 'crypto' // required for Node.js only
void (async () => {
const client = createClient({
// with session_id defined, SET and other session commands
// will affect all the consecutive queries
session_id: crypto.randomUUID(),
})
await client.command({
query: `SET output_format_json_quote_64bit_integers = 0`,
clickhouse_settings: { wait_end_of_query: 1 },
})
// this query uses output_format_json_quote_64bit_integers = 0
const rows1 = await client.query({
query: `SELECT toInt64(42)`,
format: 'JSONEachRow',
})
console.log(await rows1.json())
await client.command({
query: `SET output_format_json_quote_64bit_integers = 1`,
clickhouse_settings: { wait_end_of_query: 1 },
})
// this query uses output_format_json_quote_64bit_integers = 1
const rows2 = await client.query({
query: `SELECT toInt64(144)`,
format: 'JSONEachRow',
})
console.log(await rows2.json())
await client.close()
})()