Skip to content

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

@simonw

Description

@simonw

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"):

async def drop_table(request, datasette, database, table):
def do_drop_table(conn):
db = sqlite_utils.Database(conn)
db[table].disable_fts()
db[table].drop()
db.vacuum()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions