Weeknotes: datasette-ephemeral-tables, datasette-export
5th December 2022
Most of what I’ve been working on for the past week and a half is already documented:
- Learning Rust with ChatGPT, Copilot and Advent of Code
- A new AI game: Give me ideas for crimes to do
- The big one: Datasette’s new JSON write API: The first alpha of Datasette 1.0
- And my DjangoCon talk write-up: Coping strategies for the serial project hoarder
I also released two new Datasette plugins—one of them to support the Datasette 1.0 alpha release, and another which is still shaping up.
For the Datasette 1.0 alpha I wanted a way for people to try out the new write API, without having to install Datasette themselves.
But I didn’t want to commit to running a public writable demo that anyone could use for the long-term.
I decided to solve this using a new plugin. I built datasette-ephemeral-tables, which creates an in-memory SQLite database with tables that are automatically dropped fifteen minutes after they are created.
It’s a pretty fun little plugin. The source code is here—it works by running a task every 2 seconds which scans the
ephemeral database for new tables and adds their creation time to a dictionary, then drops any that were created more than X minutes ago.
Getting that demo to work involved figuring out CORS for the write API, a very useful new ability which I shipped in the Datasette 1.0a1 alpha release.
The datasette-export plugin is still in early alpha. The idea is to turn Datasette into a static site generator tool, by providing a CLI that can export multiple pages from a Datasette instance directly to static files on disk.
Here’s an example of it in action:
datasette export . \ --path / \ --path /plugins \ --sql "select '/plugins/' || name from content.plugins" \ --crossdb
This would run against database files, templates and plugins files in the current directory (the
. argument) and exports the
/ page and the
/plugins page, then uses a SQL query to specify a list of additional pages and exports those too.
--crossdb option is necessary because this example project (the datasette.io site) has more than one database, and using that option lets you
select ... from content.plugins to specify a particular database.
Plenty more details on what works and what’s coming next for that project in that repository’s issues.
Releases this week
datasette-public: 0.2.2—(4 releases total)—2022-12-02
Make specific Datasette tables visible to the public
datasette-ephemeral-tables: 0.2.2—(4 releases total)—2022-12-02
Provide tables that expire after a time limit
datasette: 1.0a1—(120 releases total)—2022-12-01
An open source multi-tool for exploring and publishing data
Export pages from Datasette to files on disk
TIL this week
More recent articles
- Datasette Enrichments: a new plugin framework for augmenting your data - 1st December 2023
- llamafile is the new best way to run a LLM on your own computer - 29th November 2023
- Prompt injection explained, November 2023 edition - 27th November 2023
- I'm on the Newsroom Robots podcast, with thoughts on the OpenAI board - 25th November 2023
- Weeknotes: DevDay, GitHub Universe, OpenAI chaos - 22nd November 2023
- Deciphering clues in a news article to understand how it was reported - 22nd November 2023
- Exploring GPTs: ChatGPT in a trench coat? - 15th November 2023
- Financial sustainability for open source projects at GitHub Universe - 10th November 2023
- ospeak: a CLI tool for speaking text in the terminal via OpenAI - 7th November 2023
- DALL-E 3, GPT4All, PMTiles, sqlite-migrate, datasette-edit-schema - 30th October 2023