mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Take advantage of execute_write_fn(transaction=True)
A bunch of places no longer need to do manual transaction handling thanks to this change. Refs #2277
This commit is contained in:
parent
5e0e440f2c
commit
10f9ba1a00
3 changed files with 20 additions and 26 deletions
|
|
@ -501,9 +501,8 @@ async def test_execute_write_has_correctly_prepared_connection(db):
|
|||
@pytest.mark.asyncio
|
||||
async def test_execute_write_fn_block_false(db):
|
||||
def write_fn(conn):
|
||||
with conn:
|
||||
conn.execute("delete from roadside_attractions where pk = 1;")
|
||||
row = conn.execute("select count(*) from roadside_attractions").fetchone()
|
||||
conn.execute("delete from roadside_attractions where pk = 1;")
|
||||
row = conn.execute("select count(*) from roadside_attractions").fetchone()
|
||||
return row[0]
|
||||
|
||||
task_id = await db.execute_write_fn(write_fn, block=False)
|
||||
|
|
@ -513,9 +512,8 @@ async def test_execute_write_fn_block_false(db):
|
|||
@pytest.mark.asyncio
|
||||
async def test_execute_write_fn_block_true(db):
|
||||
def write_fn(conn):
|
||||
with conn:
|
||||
conn.execute("delete from roadside_attractions where pk = 1;")
|
||||
row = conn.execute("select count(*) from roadside_attractions").fetchone()
|
||||
conn.execute("delete from roadside_attractions where pk = 1;")
|
||||
row = conn.execute("select count(*) from roadside_attractions").fetchone()
|
||||
return row[0]
|
||||
|
||||
new_count = await db.execute_write_fn(write_fn)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue