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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1083581011 | I_kwDOBm6k_c5AliJT | 1564 | _prepare_connection not called on write connections | 9599 | closed | 0 | 7571612 | 1 | 2021-12-17T20:06:47Z | 2022-01-20T21:29:43Z | 2021-12-18T01:58:44Z | OWNER | I was trying to initalize SpatiaLite in a write connection: ```pycon >>> from datasette.app import Datasette >>> ds = Datasette(memory=True, files=[], sqlite_extensions=["spatialite"]) >>> db = ds.add_memory_database('geo') >>> await db.execute_write("select InitSpatialMetadata(1)") UUID('3f143baa-4e3d-5842-a36f-4fa2f683b72f') no such function: InitSpatialMetadata ``` It looks like the code that loads additional modules only works on read-only connections, not on write connections: https://github.com/simonw/datasette/blob/92a5280d2e75c39424a75ad6226fc74400ae984f/datasette/database.py#L146-L153 Compared to: https://github.com/simonw/datasette/blob/92a5280d2e75c39424a75ad6226fc74400ae984f/datasette/database.py#L124-L132 | 107914493 | issue | { "url": "https://api.github.com/repos/simonw/datasette/issues/1564/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | |||||
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 | |||||
1083573206 | I_kwDOBm6k_c5AlgPW | 1563 | Datasette(... files=) should not be a required argument | 9599 | closed | 0 | 7571612 | 2 | 2021-12-17T19:54:18Z | 2022-01-13T22:27:18Z | 2021-12-18T02:19:40Z | OWNER | ```pycon >>> ds = Datasette(memory=True) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: __init__() missing 1 required positional argument: 'files' >>> ds = Datasette(memory=True, files=[]) ``` I wanted to create an in-memory Datasette for running some tests, no point in forcing me to pass `files=[]` to do that. | 107914493 | issue | { "url": "https://api.github.com/repos/simonw/datasette/issues/1563/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | |||||
1083718998 | I_kwDOBm6k_c5AmD1W | 1567 | Remove undocumented sqlite_functions mechanism | 9599 | closed | 0 | 7571612 | 0 | 2021-12-18T01:51:10Z | 2022-01-13T22:27:04Z | 2021-12-18T01:54:46Z | OWNER | I added this in 0b8c1b0a6da9cb8ac0d28cc90dd783de87554036 but it's never been documented and the same thing can now be achieved using the `prepare_connection` plugin hook. https://github.com/simonw/datasette/blob/0c91e59d2bbfc08884cfcf5d1b902a2f4968b7ff/datasette/app.py#L262 https://github.com/simonw/datasette/blob/0c91e59d2bbfc08884cfcf5d1b902a2f4968b7ff/datasette/app.py#L551-L552 It's used here in the tests: https://github.com/simonw/datasette/blob/69244a617b1118dcbd04a8f102173f04680cf08c/tests/fixtures.py#L156 | 107914493 | issue | { "url": "https://api.github.com/repos/simonw/datasette/issues/1567/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | |||||
1076057610 | I_kwDOBm6k_c5AI1YK | 1546 | validating the sql | 50336793 | closed | 0 | 1 | 2021-12-09T21:35:57Z | 2021-12-18T02:05:17Z | 2021-12-18T02:05:16Z | NONE | Could someone tell me that part of the code is responsible for validating the sql that guarantees that only a table can be read | 107914493 | issue | { "url": "https://api.github.com/repos/simonw/datasette/issues/1546/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed |