Coder Social home page Coder Social logo

Comments (4)

simonw avatar simonw commented on May 23, 2024

Design for this:

def vacuum(conn):
    conn.execute("vacuum")

await db.execute_isolated_fn(vacuum)

from datasette.

simonw avatar simonw commented on May 23, 2024

Implemented in a branch. Needs tests and documentation.

Another neat thing this can be used for is running "unsafe" SQLite extensions safely from within a plugin.

The plugin can define a function which takes the connection, enables the extension, then does things with it - and that extension will never be available to other connections outside of that isolated function execution.

from datasette.

simonw avatar simonw commented on May 23, 2024

I think I can test if a connection was reused or not with CREATE TEMPORARY TABLE temp_table_name (... - that should only exist within the same connection.

I'll create one in the write thread, then use the isolated mechanism to see if it's there or not and create a new one, then check if that new one is gone in the write thread again.

from datasette.

simonw avatar simonw commented on May 23, 2024

Documentation preview: https://datasette--2220.org.readthedocs.build/en/2220/internals.html#await-db-execute-isolated-fn-fn

from datasette.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.