Published
Edited
Jun 22, 2022
13 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
wasm = FileAttachment("lines0-sqljs@2.wasm").url()
Insert cell
sqljs = require(await FileAttachment("lines0-sqljs@3.js").url())
Insert cell
Insert cell
DemoSQLiteLinesDatabaseClient = async (source) => {
//Adapted from https://github.com/observablehq/stdlib/blob/main/src/sqlite.js
function load(source) {
return typeof source === "string"
? fetch(source).then(load)
: source instanceof Response || source instanceof Blob
? source.arrayBuffer().then(load)
: source instanceof ArrayBuffer
? new Uint8Array(source)
: source;
}

const [SQL, buffer] = await Promise.all([
sqljs({ locateFile: (filename, prefix) => wasm }),
Promise.resolve(source).then(load)
]);

return new SQLiteDatabaseClient(new SQL.Database(buffer));
}
Insert cell
Insert cell
db = DemoSQLiteLinesDatabaseClient()
Insert cell
db.queryRow(`select lines_version()`)
Insert cell
Insert cell
db
select lines_version(), lines_debug();
Insert cell
db
select rowid, line
from lines('alex
brian
craig')
Insert cell
Insert cell
Insert cell
Insert cell
db
select
line ->> 'color' as color,
sum(line ->> 'value') as sum
from lines(${ndjson})
group by 1
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { importCell } from "@mbostock/dataflow"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more