Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
simonw opened this issue Dec 23, 2023 · 0 comments
Closed

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

simonw opened this issue Dec 23, 2023 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@simonw
Copy link
Owner

simonw commented Dec 23, 2023

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()

@simonw simonw added the bug Something isn't working label Dec 23, 2023
@simonw simonw added this to the 0.8 milestone Feb 9, 2024
@simonw simonw closed this as completed in adf3916 Feb 9, 2024
simonw added a commit that referenced this issue Feb 18, 2024
Switch setup.py to pyproject.toml

Refs #22, #45, #46, #47, #49, #50, #51, #52, #53, #54, #55, #56, #57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant