simonw / datasette-edit-schema

Datasette plugin for modifying table schemas
Apache License 2.0
16 stars 0 forks source link

Use `db.execute_isolated_fn()` to run VACUUM, if available #47

Closed simonw closed 7 months ago

simonw commented 9 months ago

See:

To recap: plugins like https://github.com/datasette/datasette-sqlite-authorizer could result in a situation where running VACUUM against the standard Datasette write connection fails, because an authorizer prevents the required updates to one of the tables in the database.

To resolve this, Datasette now has a db.execute_isolated_fn() method which skips the prepare_connection() plugin hooks that could have added such an authorizer.

This will be a feature in Datasette 1.0, so to use it here we can use hasattr(database, "execute_isolated_fn"):

https://github.com/simonw/datasette-edit-schema/blob/542495a822a7be71e2249aa1da57d1608e31436f/datasette_edit_schema/__init__.py#L556-L561