kopia lustrzana https://github.com/simonw/datasette
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 #2277pull/2096/merge
rodzic
5e0e440f2c
commit
10f9ba1a00
|
@ -123,7 +123,6 @@ class Database:
|
|||
|
||||
async def execute_write(self, sql, params=None, block=True):
|
||||
def _inner(conn):
|
||||
with conn:
|
||||
return conn.execute(sql, params or [])
|
||||
|
||||
with trace("sql", database=self.name, sql=sql.strip(), params=params):
|
||||
|
@ -132,7 +131,6 @@ class Database:
|
|||
|
||||
async def execute_write_script(self, sql, block=True):
|
||||
def _inner(conn):
|
||||
with conn:
|
||||
return conn.executescript(sql)
|
||||
|
||||
with trace("sql", database=self.name, sql=sql.strip(), executescript=True):
|
||||
|
@ -149,7 +147,6 @@ class Database:
|
|||
count += 1
|
||||
yield param
|
||||
|
||||
with conn:
|
||||
return conn.executemany(sql, count_params(params_seq)), count
|
||||
|
||||
with trace(
|
||||
|
|
|
@ -69,7 +69,6 @@ async def populate_schema_tables(internal_db, db):
|
|||
database_name = db.name
|
||||
|
||||
def delete_everything(conn):
|
||||
with conn:
|
||||
conn.execute(
|
||||
"DELETE FROM catalog_tables WHERE database_name = ?", [database_name]
|
||||
)
|
||||
|
|
|
@ -501,7 +501,6 @@ 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()
|
||||
return row[0]
|
||||
|
@ -513,7 +512,6 @@ 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()
|
||||
return row[0]
|
||||
|
|
Ładowanie…
Reference in New Issue