Simon Willison

Results 2693 comments of Simon Willison

I was worried about if it's possible to allow access to `/fixtures` but deny access to `/fixtures?sql=...` From various answers on Stack Overflow it looks like this should handle that:...

Datasette's core URL design works like this: - `/` - the homepage - `/database` - stuff relating to that database - `/database/resource` - stuff relating to that table, SQL view...

Here's the change: ```diff diff --git a/datasette/database.py b/datasette/database.py index ffe94ea7..e56dcf03 100644 --- a/datasette/database.py +++ b/datasette/database.py @@ -85,12 +85,17 @@ class Database: return "db" def connect(self, write=False): + kwargs = {...

I tried running this `locustfile.py` using `python -m locust -f locustfile.py` and then simulating 100 users. I ran `sqlite-utils enable-wal data.db` and then `datasette data.db --root` and used the `/-/create-token`...

The currently open challenge here is this: create a `locustfile.py` which reliably triggers database locked errors when exercising a Datasette instance calling the JSON write API (and reading other endpoints...

Here's Codespaces Lotust run with WAL enabled (the macOS one above didn't have WAL enabled): ![CleanShot 2024-06-19 at 11 57 33@2x](https://github.com/simonw/datasette/assets/9599/a4fea4b3-b178-4b45-a073-767adfffb8af) ![CleanShot 2024-06-19 at 11 58 39@2x](https://github.com/simonw/datasette/assets/9599/493bd68d-6d24-4ed3-9b2b-37ccbfa2e686) I used https://github.com/datasette/studio...

I'm going to push this code anyway, and exercise it in an alpha for a bit.

Rails 8 made a similar change: - https://github.com/rails/rails/pull/50371

Here's another article about this: https://berthub.eu/articles/posts/a-brief-post-on-sqlite3-database-locked-despite-timeout/

https://github.com/simonw/datasette/blob/64a125b860eda6f821ce5a67f48b13fd173d8671/tests/test_csv.py#L192-L216