forked from grafana/xk6-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrino_test.js
28 lines (23 loc) · 896 Bytes
/
trino_test.js
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
import sql from 'k6/x/sql';
// The second argument is a Trino connection string, e.g.
// myuser[:mypassword]@myorganization-myaccount.starburstdata.com/mydatabase?schema=myschema&warehouse=mywarehouse'
const db = sql.open('trino', '');
export function setup() {
db.exec(`
CREATE TABLE IF NOT EXISTS keyvalues (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
\`key\` VARCHAR(50) NOT NULL,
value VARCHAR(50) NULL
);
`);
}
export function teardown() {
db.close();
}
export default function () {
db.exec("INSERT INTO keyvalues (`key`, value) VALUES('plugin-name', 'k6-plugin-sql');");
let results = sql.query(db, "SELECT * FROM keyvalues WHERE `key` = ?;", 'plugin-name');
for (const row of results) {
console.log(`key: ${String.fromCharCode(...row.key.toString().split(','))}, value: ${String.fromCharCode(...row.value.toString().split(','))}`);
}
}