Public
Standard SQLite client for Val Town
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

std/sqlite

This is the interface to the new scoped databases: a database for every val. Import this into your vals to interact with SQLite databases. This configures and re-exports an instance of the @libsql/client module, so all of the same methods work here: execute, batch and others.

Example

import sqlite from "https://esm.town/v/std/sqlite/main.ts"; await sqlite.execute('CREATE TABLE IF NOT EXISTS "docs" (contents TEXT)'); await sqlite.execute('INSERT INTO docs (contents) VALUES ("Hello, world!")');

Organization-scoped databases

You can import from /global.ts to access the organization-scoped database instead of the val-scoped one:

import sqlite from "https://esm.town/v/std/sqlite/global.ts"; await sqlite.execute('CREATE TABLE IF NOT EXISTS "docs" (contents TEXT)'); await sqlite.execute('INSERT INTO docs (contents) VALUES ("Hello, world!")');