mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
db.execute_write(executescript=True) option, closes #1569
This commit is contained in:
parent
85c22f4fbc
commit
9e094b7c9d
3 changed files with 31 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue