github
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | pull_request | body | repo | type | active_lock_reason | performed_via_github_app | reactions | draft | state_reason |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1083921371 | I_kwDOBm6k_c5Am1Pb | 1570 | Separate db.execute_write() into three methods | 9599 | closed | 0 | 7571612 | 2 | 2021-12-18T18:45:54Z | 2022-01-13T22:27:38Z | 2021-12-18T18:57:25Z | OWNER | > Rather than adding a `executemany=True` parameter, I'm now thinking a better design might be to have three methods: > > - `db.execute_write(sql, params=None, block=False)` > - `db.execute_write_script(sql, block=False)` > - `db.execute_write_many(sql, params_seq, block=False)` _Originally posted by @simonw in https://github.com/simonw/datasette/issues/1555#issuecomment-997267416_ | 107914493 | issue | { "url": "https://api.github.com/repos/simonw/datasette/issues/1570/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | |||||
1083895395 | I_kwDOBm6k_c5Amu5j | 1569 | db.execute_write(..., executescript=True) parameter | 9599 | closed | 0 | 7571612 | 2 | 2021-12-18T18:20:47Z | 2022-01-13T22:27:27Z | 2021-12-18T18:34:18Z | OWNER | > Idea: teach `execute_write` to accept an optional `executescript=True` parameter, like this: ```diff diff --git a/datasette/database.py b/datasette/database.py index 468e936..1a424f5 100644 --- a/datasette/database.py +++ b/datasette/database.py @@ -94,10 +94,14 @@ class Database: f"file:{self.path}{qs}", uri=True, check_same_thread=False ) - async def execute_write(self, sql, params=None, block=False): + async def execute_write(self, sql, params=None, executescript=False, block=False): + assert not executescript and params, "Cannot use params with executescript=True" def _inner(conn): with conn: - return conn.execute(sql, params or []) + if executescript: + return conn.executescript(sql) + else: + return conn.execute(sql, params or []) with trace("sql", database=self.name, sql=sql.strip(), params=params): results = await self.execute_write_fn(_inner, block=block) ``` _Originally posted by @simonw in https://github.com/simonw/datasette/issues/1555#issuecomment-997248364_ | 107914493 | issue | { "url": "https://api.github.com/repos/simonw/datasette/issues/1569/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | |||||
1083726550 | I_kwDOBm6k_c5AmFrW | 1568 | Trace should show queries on the write connection too | 9599 | closed | 0 | 7571612 | 2 | 2021-12-18T02:34:12Z | 2022-01-13T22:27:23Z | 2021-12-18T02:42:34Z | OWNER | > Here's why - `trace` only applies to read, not write SQL operations: https://github.com/simonw/datasette/blob/7c8f8aa209e4ba7bf83976f8495d67c28fbfca24/datasette/database.py#L209-L211 _Originally posted by @simonw in https://github.com/simonw/datasette/issues/1555#issuecomment-997128508_ | 107914493 | issue | { "url": "https://api.github.com/repos/simonw/datasette/issues/1568/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed |