db.execute_write(executescript=True) option, closes #1569

This commit is contained in:
Simon Willison 2021-12-18 10:28:25 -08:00
commit 9e094b7c9d
3 changed files with 31 additions and 4 deletions

View file

@ -396,6 +396,27 @@ async def test_execute_write_block_false(db):
assert "Mystery!" == rows.rows[0][0]
@pytest.mark.asyncio
async def test_execute_write_executescript(db):
await db.execute_write(
"create table foo (id integer primary key); create table bar (id integer primary key); ",
executescript=True,
block=True
)
table_names = await db.table_names()
assert {"foo", "bar"}.issubset(table_names)
@pytest.mark.asyncio
async def test_execute_write_executescript_not_allowed_with_params(db):
with pytest.raises(AssertionError):
await db.execute_write(
"update roadside_attractions set name = ? where pk = ?",
["Mystery!", 1],
executescript=True
)
@pytest.mark.asyncio
async def test_execute_write_has_correctly_prepared_connection(db):
# The sleep() function is only available if ds._prepare_connection() was called