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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more