Coder Social home page Coder Social logo

Comments (6)

simonw avatar simonw commented on July 25, 2024

I'm not going to do this for execute_isolated_fn() because that opens and then closes a whole database connection for you already, which should ensure any transactions are safely committed when it closes.

from datasette.

simonw avatar simonw commented on July 25, 2024

Did a quick test to check that this wouldn't break anything that DID have a with conn: - it looks like nesting those has no negative effect in SQLite in Python:

>>> with db:
...   with db:
...     with db:
...       db.execute('insert into foo (id) values (4)')
... 
<sqlite3.Cursor object at 0x1032f2ac0>
>>> db.execute('select * from foo').fetchall()
[(1,), (2,), (3,), (4,)]

from datasette.

simonw avatar simonw commented on July 25, 2024

Documented here: https://docs.datasette.io/en/latest/internals.html#await-db-execute-write-fn-fn-block-true-transaction-true

from datasette.

simonw avatar simonw commented on July 25, 2024

Now that I've made this change I can fix a bunch of places in the code that are using with conn: that no longer need to.

In reviewing those I also spotted that many of the JSON API write features - creating tables, inserting rows etc - were using execute_write_fn() without an explicit transaction. Those should be fixed now!

from datasette.

simonw avatar simonw commented on July 25, 2024

This change may be small but it's significant enough that I'm going to push a new alpha so I can start exercising it on Datasette Cloud.

from datasette.

simonw avatar simonw commented on July 25, 2024

Datasette 1.0a10 is out: https://docs.datasette.io/en/latest/changelog.html#a10-2024-02-17

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.