-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (33 loc) · 977 Bytes
/
index.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const gluesql = import('gluesql');
async function main() {
const { Glue } = await gluesql;
const sqls = [`
CREATE TABLE Test (
id INTEGER,
msg TEXT,
flag BOOLEAN
);`,
"INSERT INTO Test (id, msg, flag) VALUES (1, \"Hello GlueSQL\", false);",
"INSERT INTO Test (id, msg, flag) VALUES (2, \"Good Luck!\", true);",
"SELECT * FROM Test WHERE id > 0;",
];
const db = new Glue("memory");
/* other options:
*
* const db = new Glue("localstorage", "database-name");
* const db = new Glue("sessionstorage", "database-name");
*/
for (sql of sqls) {
print('[RUN]', sql);
const result = db.execute(sql)[0];
print('[RESULT]', result);
}
}
function print(title, content) {
const code = document.createElement('code');
code.style.display = 'block';
code.textContent = `${title}\t${JSON.stringify(content, null, ' ')}`;
console.log(title, content);
document.body.appendChild(code);
}
main();