My breakthrough was the realization that any text data packaged as a SQLite database could be deployed to inexpensive serverless hosting
Not a Python developer myself, I was intrigued by the use of hooks to extend Datasette and ended up looking into pluggy and how Datasette plugins use hooks.
I noticed some Datasette hooks like 'extra_template_vars' override values set by other hooks, while 'extra_body_script' simply append stuff to a list.
How does Datasette avoid plugins clashing with each other? Say one plugin writes a header and another overrides it.
I'm not too worried about extra template vars overrides though - that will only be a problem if two plugins accidentally use the same variable name. Maybe I should encourage plugins to use a namespace based on their name in the documentation though.
I do think that SQLite is a really interesting format for publishing data, and I'd love to see more places publish raw SQLite files. It's much better at preserving things like column type information and relationships between tables than CSV is.
(CKAN is an open source, traditional web app style (flask/jinja/postgresql) open data portal that powers a bunch of open data portals, including data.gov.ie)
(Love Datasette!)
Datasette avoids offset/limit pagination because it performs poorly on huge queries - and I don't want random visitors (and crawlers) hurting performance of a public instance by crawling through offset/limit of thousands of pages.
That's why table pages implement keyset pagination instead - so you can do https://congress-legislators.datasettes.com/legislators/legi... and get back records following the one with A000106, which is a fast query because the ID column has an index on it.
Supporting this with arbitrary queries is harder. One idea I had is to allow the user to specify which column and sort order should be used for keyset pagination - so you could construct a URL like this:
/?sql=select+*+from+legislators+order+by+id&_pagination_column=id
If a pagination column has been specified, Datasette would use the same trick it uses on regular table pages and add next links that way.Would that work for you?
The other, probably easier option is a setting that enables offset/limit pagination of arbitrary SQL queries - turned off by default, but easy to turn on for users who are running Datasette on a private server. If that takes several seconds people can at least opt into it.
Mahdi interviewed me about the architecture of https://datasette.io/ - topics we covered include:
- Building a modern Python app using ASGI
- Benefits of SQLite
- Designing plugin hooks
- Safely allowing SQL injection
- Using SQLite from asyncio
- The Baked Data architectural pattern
- Bundling a Python web application in Electron
- Packaging a Python for WebAssembly