Public
Script
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
import { Command } from "https://esm.town/v/pomdtr/cmdk";
import { sqlite } from "https://esm.town/v/std/sqlite?v=6";
import { markdownTable } from "npm:markdown-table";
export const runQuery: Command = async (ctx) => {
const { query } = ctx.params;
if (!query) {
return {
type: "form",
form: {
items: [
{
title: "Query",
name: "query",
type: "textarea",
textarea: {
placeholder: "SELECT * FROM table",
},
},
],
},
};
}
const res = await sqlite.execute(query);
return {
type: "detail",
detail: {
markdown: markdownTable([res.columns, ...res.rows]),
actions: [],
},
};
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
April 23, 2024