mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
db.execute_write_script() and db.execute_write_many(), closes #1570
Refs #1555
This commit is contained in:
parent
2e4ba71b53
commit
5cadc24489
4 changed files with 58 additions and 23 deletions
|
|
@ -397,10 +397,9 @@ async def test_execute_write_block_false(db):
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_execute_write_executescript(db):
|
||||
await db.execute_write(
|
||||
async def test_execute_write_script(db):
|
||||
await db.execute_write_script(
|
||||
"create table foo (id integer primary key); create table bar (id integer primary key); ",
|
||||
executescript=True,
|
||||
block=True,
|
||||
)
|
||||
table_names = await db.table_names()
|
||||
|
|
@ -408,13 +407,18 @@ async def test_execute_write_executescript(db):
|
|||
|
||||
|
||||
@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,
|
||||
)
|
||||
async def test_execute_write_many(db):
|
||||
await db.execute_write_script(
|
||||
"create table foomany (id integer primary key)",
|
||||
block=True,
|
||||
)
|
||||
await db.execute_write_many(
|
||||
"insert into foomany (id) values (?)",
|
||||
[(1,), (10,), (100,)],
|
||||
block=True,
|
||||
)
|
||||
result = await db.execute("select * from foomany")
|
||||
assert [r[0] for r in result.rows] == [1, 10, 100]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue