{"html_url": "https://github.com/simonw/datasette/issues/1727#issuecomment-1111390433", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1727", "id": 1111390433, "node_id": "IC_kwDOBm6k_c5CPnjh", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-27T19:21:02Z", "updated_at": "2022-04-27T19:21:02Z", "author_association": "OWNER", "body": "One weird thing: I noticed that in the parallel trace above the SQL query bars are wider. Mousover shows duration in ms, and I got 13ms for this query:\r\n\r\n select message as value, count(*) as n from (\r\n\r\nBut in the `?_noparallel=1` version that some query took 2.97ms.\r\n\r\nGiven those numbers though I would expect the overall page time to be MUCH worse for the parallel version - but the page load times are instead very close to each other, with parallel often winning.\r\n\r\nThis is super-weird.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1217759117, "label": "Research: demonstrate if parallel SQL queries are worthwhile"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1727#issuecomment-1111385875", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1727", "id": 1111385875, "node_id": "IC_kwDOBm6k_c5CPmcT", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-27T19:16:57Z", "updated_at": "2022-04-27T19:16:57Z", "author_association": "OWNER", "body": "I just remembered the `--setting num_sql_threads` option... which defaults to 3! https://github.com/simonw/datasette/blob/942411ef946e9a34a2094944d3423cddad27efd3/datasette/app.py#L109-L113\r\n\r\nWould explain why the first trace never seems to show more than three SQL queries executing at once.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1217759117, "label": "Research: demonstrate if parallel SQL queries are worthwhile"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1727#issuecomment-1111380282", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1727", "id": 1111380282, "node_id": "IC_kwDOBm6k_c5CPlE6", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-27T19:10:27Z", "updated_at": "2022-04-27T19:10:27Z", "author_association": "OWNER", "body": "Wrote more about that here: https://simonwillison.net/2022/Apr/27/parallel-queries/\r\n\r\nCompare https://latest-with-plugins.datasette.io/github/commits?_facet=repo&_facet=committer&_trace=1\r\n\r\n![image](https://user-images.githubusercontent.com/9599/165601503-2083c5d2-d740-405c-b34d-85570744ca82.png)\r\n\r\nWith the same thing but with parallel execution disabled:\r\n\r\nhttps://latest-with-plugins.datasette.io/github/commits?_facet=repo&_facet=committer&_trace=1&_noparallel=1\r\n\r\n![image](https://user-images.githubusercontent.com/9599/165601525-98abbfb1-5631-4040-b6bd-700948d1db6e.png)\r\n\r\nThose total page load time numbers are very similar. Is this parallel optimization worthwhile?\r\n\r\nMaybe it's only worth it on larger databases? Or maybe larger databases perform worse with this?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1217759117, "label": "Research: demonstrate if parallel SQL queries are worthwhile"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1724#issuecomment-1110585475", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1724", "id": 1110585475, "node_id": "IC_kwDOBm6k_c5CMjCD", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-27T06:15:14Z", "updated_at": "2022-04-27T06:15:14Z", "author_association": "OWNER", "body": "Yeah, that page is 438K (but only 20K gzipped).", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1216619276, "label": "?_trace=1 doesn't work on Global Power Plants demo"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1724#issuecomment-1110370095", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1724", "id": 1110370095, "node_id": "IC_kwDOBm6k_c5CLucv", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-27T00:18:30Z", "updated_at": "2022-04-27T00:18:30Z", "author_association": "OWNER", "body": "So this isn't a bug here, it's working as intended.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1216619276, "label": "?_trace=1 doesn't work on Global Power Plants demo"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1724#issuecomment-1110369004", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1724", "id": 1110369004, "node_id": "IC_kwDOBm6k_c5CLuLs", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-27T00:16:35Z", "updated_at": "2022-04-27T00:17:04Z", "author_association": "OWNER", "body": "I bet this is because it's exceeding the size limit: https://github.com/simonw/datasette/blob/da53e0360da4771ffb56a8e3eb3f7476f3168299/datasette/tracer.py#L80-L88\r\n\r\nhttps://github.com/simonw/datasette/blob/da53e0360da4771ffb56a8e3eb3f7476f3168299/datasette/tracer.py#L102-L113", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1216619276, "label": "?_trace=1 doesn't work on Global Power Plants demo"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1723#issuecomment-1110330554", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1723", "id": 1110330554, "node_id": "IC_kwDOBm6k_c5CLky6", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T23:06:20Z", "updated_at": "2022-04-26T23:06:20Z", "author_association": "OWNER", "body": "Deployed here: https://latest-with-plugins.datasette.io/github/commits?_facet=repo&_trace=1&_facet=committer", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1216508080, "label": "Research running SQL in table view in parallel using `asyncio.gather()`"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1723#issuecomment-1110305790", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1723", "id": 1110305790, "node_id": "IC_kwDOBm6k_c5CLev-", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T22:19:04Z", "updated_at": "2022-04-26T22:19:04Z", "author_association": "OWNER", "body": "I realized that seeing the total time in queries wasn't enough to understand this, because if the queries were executed in serial or parallel it should still sum up to the same amount of SQL time (roughly).\r\n\r\nInstead I need to know how long the page took to render. But that's hard to display on the page since you can't measure it until rendering has finished!\r\n\r\nSo I built an ASGI plugin to handle that measurement: https://github.com/simonw/datasette-total-page-time\r\n\r\nAnd with that plugin installed, `http://127.0.0.1:8001/global-power-plants/global-power-plants?_facet=primary_fuel&_facet=other_fuel2&_facet=other_fuel1&_parallel=1` (the parallel version) takes 377ms:\r\n\r\n\"CleanShot\r\n\r\nWhile `http://127.0.0.1:8001/global-power-plants/global-power-plants?_facet=primary_fuel&_facet=other_fuel2&_facet=other_fuel1` (the serial version) takes 762ms:\r\n\r\n\"image\"\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1216508080, "label": "Research running SQL in table view in parallel using `asyncio.gather()`"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1723#issuecomment-1110279869", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1723", "id": 1110279869, "node_id": "IC_kwDOBm6k_c5CLYa9", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T21:45:39Z", "updated_at": "2022-04-26T21:45:39Z", "author_association": "OWNER", "body": "Getting some nice traces out of this:\r\n\r\n\"CleanShot\r\n\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1216508080, "label": "Research running SQL in table view in parallel using `asyncio.gather()`"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1723#issuecomment-1110278577", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1723", "id": 1110278577, "node_id": "IC_kwDOBm6k_c5CLYGx", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T21:44:04Z", "updated_at": "2022-04-26T21:44:04Z", "author_association": "OWNER", "body": "And some simple benchmarks with `ab` - using the `?_parallel=1` hack to try it with and without a parallel `asyncio.gather()`:\r\n\r\n```\r\n~ % ab -n 100 'http://127.0.0.1:8001/global-power-plants/global-power-plants?_facet=primary_fuel&_facet=other_fuel1&_facet=other_fuel3&_facet=other_fuel2' \r\nThis is ApacheBench, Version 2.3 <$Revision: 1879490 $>\r\nCopyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\r\nLicensed to The Apache Software Foundation, http://www.apache.org/\r\n\r\nBenchmarking 127.0.0.1 (be patient).....done\r\n\r\n\r\nServer Software: uvicorn\r\nServer Hostname: 127.0.0.1\r\nServer Port: 8001\r\n\r\nDocument Path: /global-power-plants/global-power-plants?_facet=primary_fuel&_facet=other_fuel1&_facet=other_fuel3&_facet=other_fuel2\r\nDocument Length: 314187 bytes\r\n\r\nConcurrency Level: 1\r\nTime taken for tests: 68.279 seconds\r\nComplete requests: 100\r\nFailed requests: 13\r\n (Connect: 0, Receive: 0, Length: 13, Exceptions: 0)\r\nTotal transferred: 31454937 bytes\r\nHTML transferred: 31418437 bytes\r\nRequests per second: 1.46 [#/sec] (mean)\r\nTime per request: 682.787 [ms] (mean)\r\nTime per request: 682.787 [ms] (mean, across all concurrent requests)\r\nTransfer rate: 449.89 [Kbytes/sec] received\r\n\r\nConnection Times (ms)\r\n min mean[+/-sd] median max\r\nConnect: 0 0 0.0 0 0\r\nProcessing: 621 683 68.0 658 993\r\nWaiting: 620 682 68.0 657 992\r\nTotal: 621 683 68.0 658 993\r\n\r\nPercentage of the requests served within a certain time (ms)\r\n 50% 658\r\n 66% 678\r\n 75% 687\r\n 80% 711\r\n 90% 763\r\n 95% 879\r\n 98% 926\r\n 99% 993\r\n 100% 993 (longest request)\r\n\r\n\r\n----\r\n\r\nIn parallel:\r\n\r\n~ % ab -n 100 'http://127.0.0.1:8001/global-power-plants/global-power-plants?_facet=primary_fuel&_facet=other_fuel1&_facet=other_fuel3&_facet=other_fuel2&_parallel=1'\r\nThis is ApacheBench, Version 2.3 <$Revision: 1879490 $>\r\nCopyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\r\nLicensed to The Apache Software Foundation, http://www.apache.org/\r\n\r\nBenchmarking 127.0.0.1 (be patient).....done\r\n\r\n\r\nServer Software: uvicorn\r\nServer Hostname: 127.0.0.1\r\nServer Port: 8001\r\n\r\nDocument Path: /global-power-plants/global-power-plants?_facet=primary_fuel&_facet=other_fuel1&_facet=other_fuel3&_facet=other_fuel2&_parallel=1\r\nDocument Length: 315703 bytes\r\n\r\nConcurrency Level: 1\r\nTime taken for tests: 34.763 seconds\r\nComplete requests: 100\r\nFailed requests: 11\r\n (Connect: 0, Receive: 0, Length: 11, Exceptions: 0)\r\nTotal transferred: 31607988 bytes\r\nHTML transferred: 31570288 bytes\r\nRequests per second: 2.88 [#/sec] (mean)\r\nTime per request: 347.632 [ms] (mean)\r\nTime per request: 347.632 [ms] (mean, across all concurrent requests)\r\nTransfer rate: 887.93 [Kbytes/sec] received\r\n\r\nConnection Times (ms)\r\n min mean[+/-sd] median max\r\nConnect: 0 0 0.0 0 0\r\nProcessing: 311 347 28.0 338 450\r\nWaiting: 311 347 28.0 338 450\r\nTotal: 312 348 28.0 338 451\r\n\r\nPercentage of the requests served within a certain time (ms)\r\n 50% 338\r\n 66% 348\r\n 75% 361\r\n 80% 367\r\n 90% 396\r\n 95% 408\r\n 98% 436\r\n 99% 451\r\n 100% 451 (longest request)\r\n\r\n----\r\n\r\nWith concurrency 10, not parallel:\r\n\r\n~ % ab -c 10 -n 100 'http://127.0.0.1:8001/global-power-plants/global-power-plants?_facet=primary_fuel&_facet=other_fuel1&_facet=other_fuel3&_facet=other_fuel2&_parallel=' \r\nThis is ApacheBench, Version 2.3 <$Revision: 1879490 $>\r\nCopyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\r\nLicensed to The Apache Software Foundation, http://www.apache.org/\r\n\r\nBenchmarking 127.0.0.1 (be patient).....done\r\n\r\n\r\nServer Software: uvicorn\r\nServer Hostname: 127.0.0.1\r\nServer Port: 8001\r\n\r\nDocument Path: /global-power-plants/global-power-plants?_facet=primary_fuel&_facet=other_fuel1&_facet=other_fuel3&_facet=other_fuel2&_parallel=\r\nDocument Length: 314346 bytes\r\n\r\nConcurrency Level: 10\r\nTime taken for tests: 38.408 seconds\r\nComplete requests: 100\r\nFailed requests: 93\r\n (Connect: 0, Receive: 0, Length: 93, Exceptions: 0)\r\nTotal transferred: 31471333 bytes\r\nHTML transferred: 31433733 bytes\r\nRequests per second: 2.60 [#/sec] (mean)\r\nTime per request: 3840.829 [ms] (mean)\r\nTime per request: 384.083 [ms] (mean, across all concurrent requests)\r\nTransfer rate: 800.18 [Kbytes/sec] received\r\n\r\nConnection Times (ms)\r\n min mean[+/-sd] median max\r\nConnect: 0 0 0.1 0 1\r\nProcessing: 685 3719 354.0 3774 4096\r\nWaiting: 684 3707 353.7 3750 4095\r\nTotal: 685 3719 354.0 3774 4096\r\n\r\nPercentage of the requests served within a certain time (ms)\r\n 50% 3774\r\n 66% 3832\r\n 75% 3855\r\n 80% 3878\r\n 90% 3944\r\n 95% 4006\r\n 98% 4057\r\n 99% 4096\r\n 100% 4096 (longest request)\r\n\r\n\r\n----\r\n\r\nConcurrency 10 parallel:\r\n\r\n~ % ab -c 10 -n 100 'http://127.0.0.1:8001/global-power-plants/global-power-plants?_facet=primary_fuel&_facet=other_fuel1&_facet=other_fuel3&_facet=other_fuel2&_parallel=1'\r\nThis is ApacheBench, Version 2.3 <$Revision: 1879490 $>\r\nCopyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\r\nLicensed to The Apache Software Foundation, http://www.apache.org/\r\n\r\nBenchmarking 127.0.0.1 (be patient).....done\r\n\r\n\r\nServer Software: uvicorn\r\nServer Hostname: 127.0.0.1\r\nServer Port: 8001\r\n\r\nDocument Path: /global-power-plants/global-power-plants?_facet=primary_fuel&_facet=other_fuel1&_facet=other_fuel3&_facet=other_fuel2&_parallel=1\r\nDocument Length: 315703 bytes\r\n\r\nConcurrency Level: 10\r\nTime taken for tests: 36.762 seconds\r\nComplete requests: 100\r\nFailed requests: 89\r\n (Connect: 0, Receive: 0, Length: 89, Exceptions: 0)\r\nTotal transferred: 31606516 bytes\r\nHTML transferred: 31568816 bytes\r\nRequests per second: 2.72 [#/sec] (mean)\r\nTime per request: 3676.182 [ms] (mean)\r\nTime per request: 367.618 [ms] (mean, across all concurrent requests)\r\nTransfer rate: 839.61 [Kbytes/sec] received\r\n\r\nConnection Times (ms)\r\n min mean[+/-sd] median max\r\nConnect: 0 0 0.1 0 0\r\nProcessing: 381 3602 419.6 3609 4458\r\nWaiting: 381 3586 418.7 3607 4457\r\nTotal: 381 3603 419.6 3609 4458\r\n\r\nPercentage of the requests served within a certain time (ms)\r\n 50% 3609\r\n 66% 3741\r\n 75% 3791\r\n 80% 3821\r\n 90% 3972\r\n 95% 4074\r\n 98% 4386\r\n 99% 4458\r\n 100% 4458 (longest request)\r\n\r\n\r\nTrying -c 3 instead. Non parallel:\r\n\r\n~ % ab -c 3 -n 100 'http://127.0.0.1:8001/global-power-plants/global-power-plants?_facet=primary_fuel&_facet=other_fuel1&_facet=other_fuel3&_facet=other_fuel2&_parallel='\r\nThis is ApacheBench, Version 2.3 <$Revision: 1879490 $>\r\nCopyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\r\nLicensed to The Apache Software Foundation, http://www.apache.org/\r\n\r\nBenchmarking 127.0.0.1 (be patient).....done\r\n\r\n\r\nServer Software: uvicorn\r\nServer Hostname: 127.0.0.1\r\nServer Port: 8001\r\n\r\nDocument Path: /global-power-plants/global-power-plants?_facet=primary_fuel&_facet=other_fuel1&_facet=other_fuel3&_facet=other_fuel2&_parallel=\r\nDocument Length: 314346 bytes\r\n\r\nConcurrency Level: 3\r\nTime taken for tests: 39.365 seconds\r\nComplete requests: 100\r\nFailed requests: 83\r\n (Connect: 0, Receive: 0, Length: 83, Exceptions: 0)\r\nTotal transferred: 31470808 bytes\r\nHTML transferred: 31433208 bytes\r\nRequests per second: 2.54 [#/sec] (mean)\r\nTime per request: 1180.955 [ms] (mean)\r\nTime per request: 393.652 [ms] (mean, across all concurrent requests)\r\nTransfer rate: 780.72 [Kbytes/sec] received\r\n\r\nConnection Times (ms)\r\n min mean[+/-sd] median max\r\nConnect: 0 0 0.0 0 0\r\nProcessing: 731 1153 126.2 1189 1359\r\nWaiting: 730 1151 125.9 1188 1358\r\nTotal: 731 1153 126.2 1189 1359\r\n\r\nPercentage of the requests served within a certain time (ms)\r\n 50% 1189\r\n 66% 1221\r\n 75% 1234\r\n 80% 1247\r\n 90% 1296\r\n 95% 1309\r\n 98% 1343\r\n 99% 1359\r\n 100% 1359 (longest request)\r\n\r\n----\r\n\r\nParallel:\r\n\r\n~ % ab -c 3 -n 100 'http://127.0.0.1:8001/global-power-plants/global-power-plants?_facet=primary_fuel&_facet=other_fuel1&_facet=other_fuel3&_facet=other_fuel2&_parallel=1'\r\nThis is ApacheBench, Version 2.3 <$Revision: 1879490 $>\r\nCopyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\r\nLicensed to The Apache Software Foundation, http://www.apache.org/\r\n\r\nBenchmarking 127.0.0.1 (be patient).....done\r\n\r\n\r\nServer Software: uvicorn\r\nServer Hostname: 127.0.0.1\r\nServer Port: 8001\r\n\r\nDocument Path: /global-power-plants/global-power-plants?_facet=primary_fuel&_facet=other_fuel1&_facet=other_fuel3&_facet=other_fuel2&_parallel=1\r\nDocument Length: 315703 bytes\r\n\r\nConcurrency Level: 3\r\nTime taken for tests: 34.530 seconds\r\nComplete requests: 100\r\nFailed requests: 18\r\n (Connect: 0, Receive: 0, Length: 18, Exceptions: 0)\r\nTotal transferred: 31606179 bytes\r\nHTML transferred: 31568479 bytes\r\nRequests per second: 2.90 [#/sec] (mean)\r\nTime per request: 1035.902 [ms] (mean)\r\nTime per request: 345.301 [ms] (mean, across all concurrent requests)\r\nTransfer rate: 893.87 [Kbytes/sec] received\r\n\r\nConnection Times (ms)\r\n min mean[+/-sd] median max\r\nConnect: 0 0 0.0 0 0\r\nProcessing: 412 1020 104.4 1018 1280\r\nWaiting: 411 1018 104.1 1014 1275\r\nTotal: 412 1021 104.4 1018 1280\r\n\r\nPercentage of the requests served within a certain time (ms)\r\n 50% 1018\r\n 66% 1041\r\n 75% 1061\r\n 80% 1079\r\n 90% 1136\r\n 95% 1176\r\n 98% 1251\r\n 99% 1280\r\n 100% 1280 (longest request)\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1216508080, "label": "Research running SQL in table view in parallel using `asyncio.gather()`"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1723#issuecomment-1110278182", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1723", "id": 1110278182, "node_id": "IC_kwDOBm6k_c5CLYAm", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T21:43:34Z", "updated_at": "2022-04-26T21:43:34Z", "author_association": "OWNER", "body": "Here's the diff I'm using:\r\n```diff\r\ndiff --git a/datasette/views/table.py b/datasette/views/table.py\r\nindex d66adb8..f15ef1e 100644\r\n--- a/datasette/views/table.py\r\n+++ b/datasette/views/table.py\r\n@@ -1,3 +1,4 @@\r\n+import asyncio\r\n import itertools\r\n import json\r\n \r\n@@ -5,6 +6,7 @@ import markupsafe\r\n \r\n from datasette.plugins import pm\r\n from datasette.database import QueryInterrupted\r\n+from datasette import tracer\r\n from datasette.utils import (\r\n await_me_maybe,\r\n CustomRow,\r\n@@ -150,6 +152,16 @@ class TableView(DataView):\r\n default_labels=False,\r\n _next=None,\r\n _size=None,\r\n+ ):\r\n+ with tracer.trace_child_tasks():\r\n+ return await self._data_traced(request, default_labels, _next, _size)\r\n+\r\n+ async def _data_traced(\r\n+ self,\r\n+ request,\r\n+ default_labels=False,\r\n+ _next=None,\r\n+ _size=None,\r\n ):\r\n database_route = tilde_decode(request.url_vars[\"database\"])\r\n table_name = tilde_decode(request.url_vars[\"table\"])\r\n@@ -159,6 +171,20 @@ class TableView(DataView):\r\n raise NotFound(\"Database not found: {}\".format(database_route))\r\n database_name = db.name\r\n \r\n+ # For performance profiling purposes, ?_parallel=1 turns on asyncio.gather\r\n+ async def _gather_parallel(*args):\r\n+ return await asyncio.gather(*args)\r\n+\r\n+ async def _gather_sequential(*args):\r\n+ results = []\r\n+ for fn in args:\r\n+ results.append(await fn)\r\n+ return results\r\n+\r\n+ gather = (\r\n+ _gather_parallel if request.args.get(\"_parallel\") else _gather_sequential\r\n+ )\r\n+\r\n # If this is a canned query, not a table, then dispatch to QueryView instead\r\n canned_query = await self.ds.get_canned_query(\r\n database_name, table_name, request.actor\r\n@@ -174,8 +200,12 @@ class TableView(DataView):\r\n write=bool(canned_query.get(\"write\")),\r\n )\r\n \r\n- is_view = bool(await db.get_view_definition(table_name))\r\n- table_exists = bool(await db.table_exists(table_name))\r\n+ is_view, table_exists = map(\r\n+ bool,\r\n+ await gather(\r\n+ db.get_view_definition(table_name), db.table_exists(table_name)\r\n+ ),\r\n+ )\r\n \r\n # If table or view not found, return 404\r\n if not is_view and not table_exists:\r\n@@ -497,33 +527,44 @@ class TableView(DataView):\r\n )\r\n )\r\n \r\n- if not nofacet:\r\n- for facet in facet_instances:\r\n- (\r\n+ async def execute_facets():\r\n+ if not nofacet:\r\n+ # Run them in parallel\r\n+ facet_awaitables = [facet.facet_results() for facet in facet_instances]\r\n+ facet_awaitable_results = await gather(*facet_awaitables)\r\n+ for (\r\n instance_facet_results,\r\n instance_facets_timed_out,\r\n- ) = await facet.facet_results()\r\n- for facet_info in instance_facet_results:\r\n- base_key = facet_info[\"name\"]\r\n- key = base_key\r\n- i = 1\r\n- while key in facet_results:\r\n- i += 1\r\n- key = f\"{base_key}_{i}\"\r\n- facet_results[key] = facet_info\r\n- facets_timed_out.extend(instance_facets_timed_out)\r\n-\r\n- # Calculate suggested facets\r\n+ ) in facet_awaitable_results:\r\n+ for facet_info in instance_facet_results:\r\n+ base_key = facet_info[\"name\"]\r\n+ key = base_key\r\n+ i = 1\r\n+ while key in facet_results:\r\n+ i += 1\r\n+ key = f\"{base_key}_{i}\"\r\n+ facet_results[key] = facet_info\r\n+ facets_timed_out.extend(instance_facets_timed_out)\r\n+\r\n suggested_facets = []\r\n- if (\r\n- self.ds.setting(\"suggest_facets\")\r\n- and self.ds.setting(\"allow_facet\")\r\n- and not _next\r\n- and not nofacet\r\n- and not nosuggest\r\n- ):\r\n- for facet in facet_instances:\r\n- suggested_facets.extend(await facet.suggest())\r\n+\r\n+ async def execute_suggested_facets():\r\n+ # Calculate suggested facets\r\n+ if (\r\n+ self.ds.setting(\"suggest_facets\")\r\n+ and self.ds.setting(\"allow_facet\")\r\n+ and not _next\r\n+ and not nofacet\r\n+ and not nosuggest\r\n+ ):\r\n+ # Run them in parallel\r\n+ facet_suggest_awaitables = [\r\n+ facet.suggest() for facet in facet_instances\r\n+ ]\r\n+ for suggest_result in await gather(*facet_suggest_awaitables):\r\n+ suggested_facets.extend(suggest_result)\r\n+\r\n+ await gather(execute_facets(), execute_suggested_facets())\r\n \r\n # Figure out columns and rows for the query\r\n columns = [r[0] for r in results.description]\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1216508080, "label": "Research running SQL in table view in parallel using `asyncio.gather()`"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1715#issuecomment-1110265087", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1715", "id": 1110265087, "node_id": "IC_kwDOBm6k_c5CLUz_", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T21:26:17Z", "updated_at": "2022-04-26T21:26:17Z", "author_association": "OWNER", "body": "Running facets and facet suggestions in parallel using `asyncio.gather()` turns out to be a lot less hassle than I had thought - maybe I don't need `asyncinject` for this at all?\r\n\r\n```diff\r\n if not nofacet:\r\n- for facet in facet_instances:\r\n- (\r\n- instance_facet_results,\r\n- instance_facets_timed_out,\r\n- ) = await facet.facet_results()\r\n+ # Run them in parallel\r\n+ facet_awaitables = [facet.facet_results() for facet in facet_instances]\r\n+ facet_awaitable_results = await asyncio.gather(*facet_awaitables)\r\n+ for (\r\n+ instance_facet_results,\r\n+ instance_facets_timed_out,\r\n+ ) in facet_awaitable_results:\r\n for facet_info in instance_facet_results:\r\n base_key = facet_info[\"name\"]\r\n key = base_key\r\n@@ -522,8 +540,10 @@ class TableView(DataView):\r\n and not nofacet\r\n and not nosuggest\r\n ):\r\n- for facet in facet_instances:\r\n- suggested_facets.extend(await facet.suggest())\r\n+ # Run them in parallel\r\n+ facet_suggest_awaitables = [facet.suggest() for facet in facet_instances]\r\n+ for suggest_result in await asyncio.gather(*facet_suggest_awaitables):\r\n+ suggested_facets.extend(suggest_result)\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1212823665, "label": "Refactor TableView to use asyncinject"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1715#issuecomment-1110246593", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1715", "id": 1110246593, "node_id": "IC_kwDOBm6k_c5CLQTB", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T21:03:56Z", "updated_at": "2022-04-26T21:03:56Z", "author_association": "OWNER", "body": "Well this is fun... I applied this change:\r\n\r\n```diff\r\ndiff --git a/datasette/views/table.py b/datasette/views/table.py\r\nindex d66adb8..85f9e44 100644\r\n--- a/datasette/views/table.py\r\n+++ b/datasette/views/table.py\r\n@@ -1,3 +1,4 @@\r\n+import asyncio\r\n import itertools\r\n import json\r\n \r\n@@ -5,6 +6,7 @@ import markupsafe\r\n \r\n from datasette.plugins import pm\r\n from datasette.database import QueryInterrupted\r\n+from datasette import tracer\r\n from datasette.utils import (\r\n await_me_maybe,\r\n CustomRow,\r\n@@ -174,8 +176,11 @@ class TableView(DataView):\r\n write=bool(canned_query.get(\"write\")),\r\n )\r\n \r\n- is_view = bool(await db.get_view_definition(table_name))\r\n- table_exists = bool(await db.table_exists(table_name))\r\n+ with tracer.trace_child_tasks():\r\n+ is_view, table_exists = map(bool, await asyncio.gather(\r\n+ db.get_view_definition(table_name),\r\n+ db.table_exists(table_name)\r\n+ ))\r\n \r\n # If table or view not found, return 404\r\n if not is_view and not table_exists:\r\n```\r\nAnd now using https://datasette.io/plugins/datasette-pretty-traces I get this:\r\n\r\n![CleanShot 2022-04-26 at 14 03 33@2x](https://user-images.githubusercontent.com/9599/165392009-84c4399d-3e94-46d4-ba7b-a64a116cac5c.png)\r\n\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1212823665, "label": "Refactor TableView to use asyncinject"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1715#issuecomment-1110219185", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1715", "id": 1110219185, "node_id": "IC_kwDOBm6k_c5CLJmx", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T20:28:40Z", "updated_at": "2022-04-26T20:56:48Z", "author_association": "OWNER", "body": "The refactor I did in #1719 pretty much clashes with all of the changes in https://github.com/simonw/datasette/commit/5053f1ea83194ecb0a5693ad5dada5b25bf0f7e6 so I'll probably need to start my `api-extras` branch again from scratch.\r\n\r\nUsing a new `tableview-asyncinject` branch.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1212823665, "label": "Refactor TableView to use asyncinject"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1715#issuecomment-1110239536", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1715", "id": 1110239536, "node_id": "IC_kwDOBm6k_c5CLOkw", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T20:54:53Z", "updated_at": "2022-04-26T20:54:53Z", "author_association": "OWNER", "body": "`pytest tests/test_table_*` runs the tests quickly.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1212823665, "label": "Refactor TableView to use asyncinject"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1715#issuecomment-1110238896", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1715", "id": 1110238896, "node_id": "IC_kwDOBm6k_c5CLOaw", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T20:53:59Z", "updated_at": "2022-04-26T20:53:59Z", "author_association": "OWNER", "body": "I'm going to rename `database` to `database_name` and `table` to `table_name` to avoid confusion with the `Database` object as opposed to the string name for the database.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1212823665, "label": "Refactor TableView to use asyncinject"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1715#issuecomment-1110229319", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1715", "id": 1110229319, "node_id": "IC_kwDOBm6k_c5CLMFH", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T20:41:32Z", "updated_at": "2022-04-26T20:44:38Z", "author_association": "OWNER", "body": "This time I'm not going to bother with the `filter_args` thing - I'm going to just try to use `asyncinject` to execute some big high level things in parallel - facets, suggested facets, counts, the query - and then combine it with the `extras` mechanism I'm trying to introduce too.\r\n\r\nMost importantly: I want that `extra_template()` function that adds more template context for the HTML to be executed as part of an `asyncinject` flow!", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1212823665, "label": "Refactor TableView to use asyncinject"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1720#issuecomment-1110212021", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1720", "id": 1110212021, "node_id": "IC_kwDOBm6k_c5CLH21", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T20:20:27Z", "updated_at": "2022-04-26T20:20:27Z", "author_association": "OWNER", "body": "Closing this because I have a good enough idea of the design for now - the details of the parameters can be figured out when I implement this.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1215174094, "label": "Design plugin hook for extras"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1720#issuecomment-1109309683", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1720", "id": 1109309683, "node_id": "IC_kwDOBm6k_c5CHrjz", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T04:12:39Z", "updated_at": "2022-04-26T04:12:39Z", "author_association": "OWNER", "body": "I think the rough shape of the three plugin hooks is right. The detailed decisions that are needed concern what the parameters should be, which I think will mainly happen as part of:\r\n\r\n- #1715", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1215174094, "label": "Design plugin hook for extras"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1720#issuecomment-1109306070", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1720", "id": 1109306070, "node_id": "IC_kwDOBm6k_c5CHqrW", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T04:05:20Z", "updated_at": "2022-04-26T04:05:20Z", "author_association": "OWNER", "body": "The proposed plugin for annotations - allowing users to attach comments to database tables, columns and rows - would be a great application for all three of those `?_extra=` plugin hooks.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1215174094, "label": "Design plugin hook for extras"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1720#issuecomment-1109305184", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1720", "id": 1109305184, "node_id": "IC_kwDOBm6k_c5CHqdg", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T04:03:35Z", "updated_at": "2022-04-26T04:03:35Z", "author_association": "OWNER", "body": "I bet there's all kinds of interesting potential extras that could be calculated by loading the results of the query into a Pandas DataFrame.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1215174094, "label": "Design plugin hook for extras"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1720#issuecomment-1109200774", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1720", "id": 1109200774, "node_id": "IC_kwDOBm6k_c5CHQ-G", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T01:25:43Z", "updated_at": "2022-04-26T01:26:15Z", "author_association": "OWNER", "body": "Had a thought: if a custom HTML template is going to make use of stuff generated using these extras, it will need a way to tell Datasette to execute those extras even in the absence of the `?_extra=...` URL parameters.\r\n\r\nIs that necessary? Or should those kinds of plugins use the existing `extra_template_vars` hook instead?\r\n\r\nOr maybe the `extra_template_vars` hook gets redesigned so it can depend on other `extras` in some way?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1215174094, "label": "Design plugin hook for extras"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1720#issuecomment-1109200335", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1720", "id": 1109200335, "node_id": "IC_kwDOBm6k_c5CHQ3P", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T01:24:47Z", "updated_at": "2022-04-26T01:24:47Z", "author_association": "OWNER", "body": "Sketching out a `?_extra=statistics` table plugin:\r\n\r\n```python\r\nfrom datasette import hookimpl\r\n\r\n@hookimpl\r\ndef register_table_extras(datasette):\r\n return [statistics]\r\n\r\nasync def statistics(datasette, query, columns, sql):\r\n # ... need to figure out which columns are integer/floats\r\n # then build and execute a SQL query that calculates sum/avg/etc for each column\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1215174094, "label": "Design plugin hook for extras"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/428#issuecomment-1109190401", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/428", "id": 1109190401, "node_id": "IC_kwDOCGYnMM5CHOcB", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T01:05:29Z", "updated_at": "2022-04-26T01:05:29Z", "author_association": "OWNER", "body": "Django makes extensive use of savepoints for nested transactions: https://docs.djangoproject.com/en/4.0/topics/db/transactions/#savepoints", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1215216249, "label": "Research adding support for savepoints"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1720#issuecomment-1109174715", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1720", "id": 1109174715, "node_id": "IC_kwDOBm6k_c5CHKm7", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T00:40:13Z", "updated_at": "2022-04-26T00:43:33Z", "author_association": "OWNER", "body": "Some of the things I'd like to use `?_extra=` for, that may or not make sense as plugins:\r\n\r\n- Performance breakdown information, maybe including explain output for a query/table\r\n- Information about the tables that were consulted in a query - imagine pulling in additional table metadata\r\n- Statistical aggregates against the full set of results. This may well be a Datasette core feature at some point in the future, but being able to provide it early as a plugin would be really cool.\r\n- For tables, what are the other tables they can join against?\r\n- Suggested facets\r\n- Facet results themselves\r\n- New custom facets I haven't thought of - though the `register_facet_classes` hook covers that already\r\n- Table schema\r\n- Table metadata\r\n- Analytics - how many times has this table been queried? Would be a plugin thing\r\n- For geospatial data, how about a GeoJSON polygon that represents the bounding box for all returned results? Effectively this is an extra aggregation.\r\n\r\nLooking at https://github-to-sqlite.dogsheep.net/github/commits.json?_labels=on&_shape=objects for inspiration.\r\n\r\nI think there's a separate potential mechanism in the future that lets you add custom columns to a table. This would affect `.csv` and the HTML presentation too, which makes it a different concept from the `?_extra=` hook that affects the JSON export (and the context that is fed to the HTML templates).", "reactions": "{\"total_count\": 1, \"+1\": 1, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1215174094, "label": "Design plugin hook for extras"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1720#issuecomment-1109171871", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1720", "id": 1109171871, "node_id": "IC_kwDOBm6k_c5CHJ6f", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T00:34:48Z", "updated_at": "2022-04-26T00:34:48Z", "author_association": "OWNER", "body": "Let's try sketching out a `register_table_extras` plugin for something new.\r\n\r\nThe first idea I came up with suggests adding new fields to the individual row records that come back - my mental model for extras so far has been that they add new keys to the root object.\r\n\r\nSo if a table result looked like this:\r\n\r\n```json\r\n{\r\n \"rows\": [\r\n {\"id\": 1, \"name\": \"Cleo\"},\r\n {\"id\": 2, \"name\": \"Suna\"}\r\n ],\r\n \"next_url\": null\r\n}\r\n```\r\nI was initially thinking that `?_extra=facets` would add a `\"facets\": {...}` key to that root object.\r\n\r\nHere's a plugin idea I came up with that would probably justify adding to the individual row objects instead:\r\n\r\n- `?_extra=check404s` - does an async `HEAD` request against every column value that looks like a URL and checks if it returns a 404\r\n\r\nThis could also work by adding a `\"check404s\": {\"url-here\": 200}` key to the root object though.\r\n\r\nI think I need some better plugin concepts before committing to this new hook. There's overlap between this and how I want the enrichments mechanism ([see here](https://simonwillison.net/2021/Jan/17/weeknotes-still-pretty-distracted/)) to work.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1215174094, "label": "Design plugin hook for extras"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1720#issuecomment-1109165411", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1720", "id": 1109165411, "node_id": "IC_kwDOBm6k_c5CHIVj", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T00:22:42Z", "updated_at": "2022-04-26T00:22:42Z", "author_association": "OWNER", "body": "Passing `pk_values` to the plugin hook feels odd. I think I'd pass a `row` object instead and let the code look up the primary key values on that row (by introspecting the primary keys for the table).", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1215174094, "label": "Design plugin hook for extras"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1720#issuecomment-1109164803", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1720", "id": 1109164803, "node_id": "IC_kwDOBm6k_c5CHIMD", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T00:21:40Z", "updated_at": "2022-04-26T00:21:40Z", "author_association": "OWNER", "body": "What would the existing https://latest.datasette.io/fixtures/simple_primary_key/1.json?_extras=foreign_key_tables feature look like if it was re-imagined as a `register_row_extras()` plugin?\r\n\r\nRough sketch, copying most of the code from https://github.com/simonw/datasette/blob/579f59dcec43a91dd7d404e00b87a00afd8515f2/datasette/views/row.py#L98\r\n\r\n```python\r\nfrom datasette import hookimpl\r\n\r\n@hookimpl\r\ndef register_row_extras(datasette):\r\n return [foreign_key_tables]\r\n\r\nasync def foreign_key_tables(datasette, database, table, pk_values):\r\n if len(pk_values) != 1:\r\n return []\r\n db = datasette.get_database(database)\r\n all_foreign_keys = await db.get_all_foreign_keys()\r\n foreign_keys = all_foreign_keys[table][\"incoming\"]\r\n if len(foreign_keys) == 0:\r\n return []\r\n\r\n sql = \"select \" + \", \".join(\r\n [\r\n \"(select count(*) from {table} where {column}=:id)\".format(\r\n table=escape_sqlite(fk[\"other_table\"]),\r\n column=escape_sqlite(fk[\"other_column\"]),\r\n )\r\n for fk in foreign_keys\r\n ]\r\n )\r\n try:\r\n rows = list(await db.execute(sql, {\"id\": pk_values[0]}))\r\n except QueryInterrupted:\r\n # Almost certainly hit the timeout\r\n return []\r\n\r\n foreign_table_counts = dict(\r\n zip(\r\n [(fk[\"other_table\"], fk[\"other_column\"]) for fk in foreign_keys],\r\n list(rows[0]),\r\n )\r\n )\r\n foreign_key_tables = []\r\n for fk in foreign_keys:\r\n count = (\r\n foreign_table_counts.get((fk[\"other_table\"], fk[\"other_column\"])) or 0\r\n )\r\n key = fk[\"other_column\"]\r\n if key.startswith(\"_\"):\r\n key += \"__exact\"\r\n link = \"{}?{}={}\".format(\r\n self.ds.urls.table(database, fk[\"other_table\"]),\r\n key,\r\n \",\".join(pk_values),\r\n )\r\n foreign_key_tables.append({**fk, **{\"count\": count, \"link\": link}})\r\n return foreign_key_tables\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1215174094, "label": "Design plugin hook for extras"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1720#issuecomment-1109162123", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1720", "id": 1109162123, "node_id": "IC_kwDOBm6k_c5CHHiL", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T00:16:42Z", "updated_at": "2022-04-26T00:16:51Z", "author_association": "OWNER", "body": "Actually I'm going to imitate the existing `register_*` hooks:\r\n\r\n- `def register_output_renderer(datasette)`\r\n- `def register_facet_classes()`\r\n- `def register_routes(datasette)`\r\n- `def register_commands(cli)`\r\n- `def register_magic_parameters(datasette)`\r\n\r\nSo I'm going to call the new hooks:\r\n\r\n- `register_table_extras(datasette)`\r\n- `register_row_extras(datasette)`\r\n- `register_query_extras(datasette)`\r\n\r\nThey'll return a list of `async def` functions. The names of those functions will become the names of the extras.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1215174094, "label": "Design plugin hook for extras"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1720#issuecomment-1109160226", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1720", "id": 1109160226, "node_id": "IC_kwDOBm6k_c5CHHEi", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T00:14:11Z", "updated_at": "2022-04-26T00:14:11Z", "author_association": "OWNER", "body": "There are four existing plugin hooks that include the word \"extra\" but use it to mean something else - to mean additional CSS/JS/variables to be injected into the page:\r\n\r\n- `def extra_css_urls(...)`\r\n- `def extra_js_urls(...)`\r\n- `def extra_body_script(...)`\r\n- `def extra_template_vars(...)`\r\n\r\nI think `extra_*` and `*_extras` are different enough that they won't be confused with each other.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1215174094, "label": "Design plugin hook for extras"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1720#issuecomment-1109159307", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1720", "id": 1109159307, "node_id": "IC_kwDOBm6k_c5CHG2L", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T00:12:28Z", "updated_at": "2022-04-26T00:12:28Z", "author_association": "OWNER", "body": "I'm going to keep table and row separate. So I think I need to add three new plugin hooks:\r\n\r\n- `table_extras()`\r\n- `row_extras()`\r\n- `query_extras()`", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1215174094, "label": "Design plugin hook for extras"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1720#issuecomment-1109158903", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1720", "id": 1109158903, "node_id": "IC_kwDOBm6k_c5CHGv3", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-26T00:11:42Z", "updated_at": "2022-04-26T00:11:42Z", "author_association": "OWNER", "body": "Places this plugin hook (or hooks?) should be able to affect:\r\n\r\n- JSON for a table/view\r\n- JSON for a row\r\n- JSON for a canned query\r\n- JSON for a custom arbitrary query\r\n\r\nI'm going to combine those last two, which means there are three places. But maybe I can combine the table one and the row one as well?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1215174094, "label": "Design plugin hook for extras"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1719#issuecomment-1108907238", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1719", "id": 1108907238, "node_id": "IC_kwDOBm6k_c5CGJTm", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-25T18:34:21Z", "updated_at": "2022-04-25T18:34:21Z", "author_association": "OWNER", "body": "Well this refactor turned out to be pretty quick and really does greatly simplify both the `RowView` and `TableView` classes. Very happy with this.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1214859703, "label": "Refactor `RowView` and remove `RowTableShared`"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/262#issuecomment-1108890170", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/262", "id": 1108890170, "node_id": "IC_kwDOBm6k_c5CGFI6", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-25T18:17:09Z", "updated_at": "2022-04-25T18:18:39Z", "author_association": "OWNER", "body": "I spotted in https://github.com/simonw/datasette/issues/1719#issuecomment-1108888494 that there's actually already an undocumented implementation of `?_extras=foreign_key_tables` - https://latest.datasette.io/fixtures/simple_primary_key/1.json?_extras=foreign_key_tables\r\n\r\nI added that feature all the way back in November 2017! https://github.com/simonw/datasette/commit/a30c5b220c15360d575e94b0e67f3255e120b916", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 323658641, "label": "Add ?_extra= mechanism for requesting extra properties in JSON"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1719#issuecomment-1108888494", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1719", "id": 1108888494, "node_id": "IC_kwDOBm6k_c5CGEuu", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-25T18:15:42Z", "updated_at": "2022-04-25T18:15:42Z", "author_association": "OWNER", "body": "Here's an undocumented feature I forgot existed: https://latest.datasette.io/fixtures/simple_primary_key/1.json?_extras=foreign_key_tables\r\n\r\n`?_extras=foreign_key_tables`\r\n\r\nhttps://github.com/simonw/datasette/blob/0bc5186b7bb4fc82392df08f99a9132f84dcb331/datasette/views/table.py#L1021-L1024\r\n\r\nIt's even covered by the tests:\r\n\r\nhttps://github.com/simonw/datasette/blob/b9c2b1cfc8692b9700416db98721fa3ec982f6be/tests/test_api.py#L691-L703", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1214859703, "label": "Refactor `RowView` and remove `RowTableShared`"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1719#issuecomment-1108884171", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1719", "id": 1108884171, "node_id": "IC_kwDOBm6k_c5CGDrL", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-25T18:10:46Z", "updated_at": "2022-04-25T18:12:45Z", "author_association": "OWNER", "body": "It looks like the only class method from that shared class needed by `RowView` is `self.display_columns_and_rows()`.\r\n\r\nWhich I've been wanting to refactor to provide to `QueryView` too:\r\n\r\n- #715", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1214859703, "label": "Refactor `RowView` and remove `RowTableShared`"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1715#issuecomment-1108875068", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1715", "id": 1108875068, "node_id": "IC_kwDOBm6k_c5CGBc8", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-25T18:03:13Z", "updated_at": "2022-04-25T18:06:33Z", "author_association": "OWNER", "body": "The `RowTableShared` class is making this a whole lot more complicated.\r\n\r\nI'm going to split the `RowView` view out into an entirely separate `views/row.py` module.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1212823665, "label": "Refactor TableView to use asyncinject"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1715#issuecomment-1108877454", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1715", "id": 1108877454, "node_id": "IC_kwDOBm6k_c5CGCCO", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-25T18:04:27Z", "updated_at": "2022-04-25T18:04:27Z", "author_association": "OWNER", "body": "Pushed my WIP on this to the `api-extras` branch: 5053f1ea83194ecb0a5693ad5dada5b25bf0f7e6", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1212823665, "label": "Refactor TableView to use asyncinject"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1718#issuecomment-1107873311", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1718", "id": 1107873311, "node_id": "IC_kwDOBm6k_c5CCM4f", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-24T16:24:14Z", "updated_at": "2022-04-24T16:24:14Z", "author_association": "OWNER", "body": "Wrote up what I learned in a TIL: https://til.simonwillison.net/sphinx/blacken-docs", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1213683988, "label": "Code examples in the documentation should be formatted with Black"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1718#issuecomment-1107873271", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1718", "id": 1107873271, "node_id": "IC_kwDOBm6k_c5CCM33", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-24T16:23:57Z", "updated_at": "2022-04-24T16:23:57Z", "author_association": "OWNER", "body": "Turns out I didn't need that `git diff-index` trick after all - the `blacken-docs` command returns a non-zero exit code if it changes any files.\r\n\r\nSubmitted a documentation PR to that project instead:\r\n\r\n- https://github.com/asottile/blacken-docs/pull/162", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1213683988, "label": "Code examples in the documentation should be formatted with Black"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1718#issuecomment-1107870788", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1718", "id": 1107870788, "node_id": "IC_kwDOBm6k_c5CCMRE", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-24T16:09:23Z", "updated_at": "2022-04-24T16:09:23Z", "author_association": "OWNER", "body": "One more attempt at testing the `git diff-index` trick.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1213683988, "label": "Code examples in the documentation should be formatted with Black"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1718#issuecomment-1107869884", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1718", "id": 1107869884, "node_id": "IC_kwDOBm6k_c5CCMC8", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-24T16:04:03Z", "updated_at": "2022-04-24T16:04:03Z", "author_association": "OWNER", "body": "OK, I'm expecting this one to fail at the `git diff-index --quiet HEAD --` check.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1213683988, "label": "Code examples in the documentation should be formatted with Black"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1718#issuecomment-1107869556", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1718", "id": 1107869556, "node_id": "IC_kwDOBm6k_c5CCL90", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-24T16:02:27Z", "updated_at": "2022-04-24T16:02:27Z", "author_association": "OWNER", "body": "Looking at that first error it appears to be a place where I had deliberately omitted the body of the function:\r\n\r\nhttps://github.com/simonw/datasette/blob/36573638b0948174ae237d62e6369b7d55220d7f/docs/internals.rst#L196-L211\r\n\r\nI can use `...` as the function body here to get it to pass.\r\n\r\nFixing those warnings actually helped me spot a couple of bugs, so I'm glad this happened.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1213683988, "label": "Code examples in the documentation should be formatted with Black"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1718#issuecomment-1107868585", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1718", "id": 1107868585, "node_id": "IC_kwDOBm6k_c5CCLup", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-24T15:57:10Z", "updated_at": "2022-04-24T15:57:19Z", "author_association": "OWNER", "body": "The tests failed there because of what I thought were warnings but turn out to be treated as errors:\r\n```\r\n% blacken-docs -l 60 docs/*.rst \r\ndocs/internals.rst:196: code block parse error Cannot parse: 14:0: \r\ndocs/json_api.rst:449: code block parse error Cannot parse: 1:0: \r\ndocs/testing_plugins.rst:135: code block parse error Cannot parse: 5:0: \r\n% echo $?\r\n1\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1213683988, "label": "Code examples in the documentation should be formatted with Black"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1718#issuecomment-1107867281", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1718", "id": 1107867281, "node_id": "IC_kwDOBm6k_c5CCLaR", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-24T15:49:23Z", "updated_at": "2022-04-24T15:49:23Z", "author_association": "OWNER", "body": "I'm going to push the first commit with a deliberate missing formatting to check that the tests fail.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1213683988, "label": "Code examples in the documentation should be formatted with Black"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1718#issuecomment-1107866013", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1718", "id": 1107866013, "node_id": "IC_kwDOBm6k_c5CCLGd", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-24T15:42:07Z", "updated_at": "2022-04-24T15:42:07Z", "author_association": "OWNER", "body": "In the absence of `--check` I can use this to detect if changes are applied:\r\n```zsh\r\n% git diff-index --quiet HEAD --\r\n% echo $? \r\n0\r\n% blacken-docs -l 60 docs/*.rst\r\ndocs/authentication.rst: Rewriting...\r\n...\r\n% git diff-index --quiet HEAD --\r\n% echo $? \r\n1\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1213683988, "label": "Code examples in the documentation should be formatted with Black"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1718#issuecomment-1107865493", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1718", "id": 1107865493, "node_id": "IC_kwDOBm6k_c5CCK-V", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-24T15:39:02Z", "updated_at": "2022-04-24T15:39:02Z", "author_association": "OWNER", "body": "There's no `blacken-docs --check` option so I filed a feature request:\r\n- https://github.com/asottile/blacken-docs/issues/161", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1213683988, "label": "Code examples in the documentation should be formatted with Black"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1718#issuecomment-1107863924", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1718", "id": 1107863924, "node_id": "IC_kwDOBm6k_c5CCKl0", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-24T15:30:03Z", "updated_at": "2022-04-24T15:30:03Z", "author_association": "OWNER", "body": "On the one hand, I'm not crazy about some of the indentation decisions Black made here - in particular this one, which I had indented deliberately for readability:\r\n```diff\r\n diff --git a/docs/authentication.rst b/docs/authentication.rst\r\nindex 0d98cf8..8008023 100644\r\n--- a/docs/authentication.rst\r\n+++ b/docs/authentication.rst\r\n@@ -381,11 +381,7 @@ Authentication plugins can set signed ``ds_actor`` cookies themselves like so:\r\n .. code-block:: python\r\n \r\n response = Response.redirect(\"/\")\r\n- response.set_cookie(\"ds_actor\", datasette.sign({\r\n- \"a\": {\r\n- \"id\": \"cleopaws\"\r\n- }\r\n- }, \"actor\"))\r\n+ response.set_cookie(\"ds_actor\", datasette.sign({\"a\": {\"id\": \"cleopaws\"}}, \"actor\"))\r\n```\r\nBut... consistency is a virtue. Maybe I'm OK with just this one disagreement?\r\n\r\nAlso: I've been mentally trying to keep the line lengths a bit shorter to help them be more readable on mobile devices.\r\n\r\nI'll try a different line length using `blacken-docs -l 60 docs/*.rst` instead.\r\n\r\nI like this more - here's the result for that example:\r\n```diff\r\ndiff --git a/docs/authentication.rst b/docs/authentication.rst\r\nindex 0d98cf8..2496073 100644\r\n--- a/docs/authentication.rst\r\n+++ b/docs/authentication.rst\r\n@@ -381,11 +381,10 @@ Authentication plugins can set signed ``ds_actor`` cookies themselves like so:\r\n .. code-block:: python\r\n \r\n response = Response.redirect(\"/\")\r\n- response.set_cookie(\"ds_actor\", datasette.sign({\r\n- \"a\": {\r\n- \"id\": \"cleopaws\"\r\n- }\r\n- }, \"actor\"))\r\n+ response.set_cookie(\r\n+ \"ds_actor\",\r\n+ datasette.sign({\"a\": {\"id\": \"cleopaws\"}}, \"actor\"),\r\n+ )\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1213683988, "label": "Code examples in the documentation should be formatted with Black"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1718#issuecomment-1107863365", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1718", "id": 1107863365, "node_id": "IC_kwDOBm6k_c5CCKdF", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-24T15:26:41Z", "updated_at": "2022-04-24T15:26:41Z", "author_association": "OWNER", "body": "Tried this:\r\n```\r\npip install blacken-docs\r\nblacken-docs docs/*.rst\r\ngit diff | pbcopy\r\n```\r\nGot this:\r\n```diff\r\n diff --git a/docs/authentication.rst b/docs/authentication.rst\r\nindex 0d98cf8..8008023 100644\r\n--- a/docs/authentication.rst\r\n+++ b/docs/authentication.rst\r\n@@ -381,11 +381,7 @@ Authentication plugins can set signed ``ds_actor`` cookies themselves like so:\r\n .. code-block:: python\r\n \r\n response = Response.redirect(\"/\")\r\n- response.set_cookie(\"ds_actor\", datasette.sign({\r\n- \"a\": {\r\n- \"id\": \"cleopaws\"\r\n- }\r\n- }, \"actor\"))\r\n+ response.set_cookie(\"ds_actor\", datasette.sign({\"a\": {\"id\": \"cleopaws\"}}, \"actor\"))\r\n \r\n Note that you need to pass ``\"actor\"`` as the namespace to :ref:`datasette_sign`.\r\n \r\n@@ -412,12 +408,16 @@ To include an expiry, add a ``\"e\"`` key to the cookie value containing a `base62\r\n expires_at = int(time.time()) + (24 * 60 * 60)\r\n \r\n response = Response.redirect(\"/\")\r\n- response.set_cookie(\"ds_actor\", datasette.sign({\r\n- \"a\": {\r\n- \"id\": \"cleopaws\"\r\n- },\r\n- \"e\": baseconv.base62.encode(expires_at),\r\n- }, \"actor\"))\r\n+ response.set_cookie(\r\n+ \"ds_actor\",\r\n+ datasette.sign(\r\n+ {\r\n+ \"a\": {\"id\": \"cleopaws\"},\r\n+ \"e\": baseconv.base62.encode(expires_at),\r\n+ },\r\n+ \"actor\",\r\n+ ),\r\n+ )\r\n \r\n The resulting cookie will encode data that looks something like this:\r\n \r\ndiff --git a/docs/spatialite.rst b/docs/spatialite.rst\r\nindex d1b300b..556bad8 100644\r\n--- a/docs/spatialite.rst\r\n+++ b/docs/spatialite.rst\r\n@@ -58,19 +58,22 @@ Here's a recipe for taking a table with existing latitude and longitude columns,\r\n .. code-block:: python\r\n \r\n import sqlite3\r\n- conn = sqlite3.connect('museums.db')\r\n+\r\n+ conn = sqlite3.connect(\"museums.db\")\r\n # Lead the spatialite extension:\r\n conn.enable_load_extension(True)\r\n- conn.load_extension('/usr/local/lib/mod_spatialite.dylib')\r\n+ conn.load_extension(\"/usr/local/lib/mod_spatialite.dylib\")\r\n # Initialize spatial metadata for this database:\r\n- conn.execute('select InitSpatialMetadata(1)')\r\n+ conn.execute(\"select InitSpatialMetadata(1)\")\r\n # Add a geometry column called point_geom to our museums table:\r\n conn.execute(\"SELECT AddGeometryColumn('museums', 'point_geom', 4326, 'POINT', 2);\")\r\n # Now update that geometry column with the lat/lon points\r\n- conn.execute('''\r\n+ conn.execute(\r\n+ \"\"\"\r\n UPDATE museums SET\r\n point_geom = GeomFromText('POINT('||\"longitude\"||' '||\"latitude\"||')',4326);\r\n- ''')\r\n+ \"\"\"\r\n+ )\r\n # Now add a spatial index to that column\r\n conn.execute('select CreateSpatialIndex(\"museums\", \"point_geom\");')\r\n # If you don't commit your changes will not be persisted:\r\n@@ -186,13 +189,14 @@ Here's Python code to create a SQLite database, enable SpatiaLite, create a plac\r\n .. code-block:: python\r\n \r\n import sqlite3\r\n- conn = sqlite3.connect('places.db')\r\n+\r\n+ conn = sqlite3.connect(\"places.db\")\r\n # Enable SpatialLite extension\r\n conn.enable_load_extension(True)\r\n- conn.load_extension('/usr/local/lib/mod_spatialite.dylib')\r\n+ conn.load_extension(\"/usr/local/lib/mod_spatialite.dylib\")\r\n # Create the masic countries table\r\n- conn.execute('select InitSpatialMetadata(1)')\r\n- conn.execute('create table places (id integer primary key, name text);')\r\n+ conn.execute(\"select InitSpatialMetadata(1)\")\r\n+ conn.execute(\"create table places (id integer primary key, name text);\")\r\n # Add a MULTIPOLYGON Geometry column\r\n conn.execute(\"SELECT AddGeometryColumn('places', 'geom', 4326, 'MULTIPOLYGON', 2);\")\r\n # Add a spatial index against the new column\r\n@@ -201,13 +205,17 @@ Here's Python code to create a SQLite database, enable SpatiaLite, create a plac\r\n from shapely.geometry.multipolygon import MultiPolygon\r\n from shapely.geometry import shape\r\n import requests\r\n- geojson = requests.get('https://data.whosonfirst.org/404/227/475/404227475.geojson').json()\r\n+\r\n+ geojson = requests.get(\r\n+ \"https://data.whosonfirst.org/404/227/475/404227475.geojson\"\r\n+ ).json()\r\n # Convert to \"Well Known Text\" format\r\n- wkt = shape(geojson['geometry']).wkt\r\n+ wkt = shape(geojson[\"geometry\"]).wkt\r\n # Insert and commit the record\r\n- conn.execute(\"INSERT INTO places (id, name, geom) VALUES(null, ?, GeomFromText(?, 4326))\", (\r\n- \"Wales\", wkt\r\n- ))\r\n+ conn.execute(\r\n+ \"INSERT INTO places (id, name, geom) VALUES(null, ?, GeomFromText(?, 4326))\",\r\n+ (\"Wales\", wkt),\r\n+ )\r\n conn.commit()\r\n \r\n Querying polygons using within()\r\ndiff --git a/docs/writing_plugins.rst b/docs/writing_plugins.rst\r\nindex bd60a4b..5af01f6 100644\r\n--- a/docs/writing_plugins.rst\r\n+++ b/docs/writing_plugins.rst\r\n@@ -18,9 +18,10 @@ The quickest way to start writing a plugin is to create a ``my_plugin.py`` file\r\n \r\n from datasette import hookimpl\r\n \r\n+\r\n @hookimpl\r\n def prepare_connection(conn):\r\n- conn.create_function('hello_world', 0, lambda: 'Hello world!')\r\n+ conn.create_function(\"hello_world\", 0, lambda: \"Hello world!\")\r\n \r\n If you save this in ``plugins/my_plugin.py`` you can then start Datasette like this::\r\n \r\n@@ -60,22 +61,18 @@ The example consists of two files: a ``setup.py`` file that defines the plugin:\r\n \r\n from setuptools import setup\r\n \r\n- VERSION = '0.1'\r\n+ VERSION = \"0.1\"\r\n \r\n setup(\r\n- name='datasette-plugin-demos',\r\n- description='Examples of plugins for Datasette',\r\n- author='Simon Willison',\r\n- url='https://github.com/simonw/datasette-plugin-demos',\r\n- license='Apache License, Version 2.0',\r\n+ name=\"datasette-plugin-demos\",\r\n+ description=\"Examples of plugins for Datasette\",\r\n+ author=\"Simon Willison\",\r\n+ url=\"https://github.com/simonw/datasette-plugin-demos\",\r\n+ license=\"Apache License, Version 2.0\",\r\n version=VERSION,\r\n- py_modules=['datasette_plugin_demos'],\r\n- entry_points={\r\n- 'datasette': [\r\n- 'plugin_demos = datasette_plugin_demos'\r\n- ]\r\n- },\r\n- install_requires=['datasette']\r\n+ py_modules=[\"datasette_plugin_demos\"],\r\n+ entry_points={\"datasette\": [\"plugin_demos = datasette_plugin_demos\"]},\r\n+ install_requires=[\"datasette\"],\r\n )\r\n \r\n And a Python module file, ``datasette_plugin_demos.py``, that implements the plugin:\r\n@@ -88,12 +85,12 @@ And a Python module file, ``datasette_plugin_demos.py``, that implements the plu\r\n \r\n @hookimpl\r\n def prepare_jinja2_environment(env):\r\n- env.filters['uppercase'] = lambda u: u.upper()\r\n+ env.filters[\"uppercase\"] = lambda u: u.upper()\r\n \r\n \r\n @hookimpl\r\n def prepare_connection(conn):\r\n- conn.create_function('random_integer', 2, random.randint)\r\n+ conn.create_function(\"random_integer\", 2, random.randint)\r\n \r\n \r\n Having built a plugin in this way you can turn it into an installable package using the following command::\r\n@@ -123,11 +120,13 @@ To bundle the static assets for a plugin in the package that you publish to PyPI\r\n \r\n .. code-block:: python\r\n \r\n- package_data={\r\n- 'datasette_plugin_name': [\r\n- 'static/plugin.js',\r\n- ],\r\n- },\r\n+ package_data = (\r\n+ {\r\n+ \"datasette_plugin_name\": [\r\n+ \"static/plugin.js\",\r\n+ ],\r\n+ },\r\n+ )\r\n \r\n Where ``datasette_plugin_name`` is the name of the plugin package (note that it uses underscores, not hyphens) and ``static/plugin.js`` is the path within that package to the static file.\r\n \r\n@@ -152,11 +151,13 @@ Templates should be bundled for distribution using the same ``package_data`` mec\r\n \r\n .. code-block:: python\r\n \r\n- package_data={\r\n- 'datasette_plugin_name': [\r\n- 'templates/my_template.html',\r\n- ],\r\n- },\r\n+ package_data = (\r\n+ {\r\n+ \"datasette_plugin_name\": [\r\n+ \"templates/my_template.html\",\r\n+ ],\r\n+ },\r\n+ )\r\n \r\n You can also use wildcards here such as ``templates/*.html``. See `datasette-edit-schema `__ for an example of this pattern.\r\n ```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1213683988, "label": "Code examples in the documentation should be formatted with Black"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1718#issuecomment-1107862882", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1718", "id": 1107862882, "node_id": "IC_kwDOBm6k_c5CCKVi", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-24T15:23:56Z", "updated_at": "2022-04-24T15:23:56Z", "author_association": "OWNER", "body": "Found https://github.com/asottile/blacken-docs via\r\n- https://github.com/psf/black/issues/294", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1213683988, "label": "Code examples in the documentation should be formatted with Black"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1717#issuecomment-1107848097", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1717", "id": 1107848097, "node_id": "IC_kwDOBm6k_c5CCGuh", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-24T14:02:37Z", "updated_at": "2022-04-24T14:02:37Z", "author_association": "OWNER", "body": "This is a neat feature, thanks!", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1213281044, "label": "Add timeout option to Cloudrun build"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1717#issuecomment-1107459446", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1717", "id": 1107459446, "node_id": "IC_kwDOBm6k_c5CAn12", "user": {"value": 22429695, "label": "codecov[bot]"}, "created_at": "2022-04-23T11:56:36Z", "updated_at": "2022-04-23T11:56:36Z", "author_association": "NONE", "body": "# [Codecov](https://codecov.io/gh/simonw/datasette/pull/1717?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) Report\n> Merging [#1717](https://codecov.io/gh/simonw/datasette/pull/1717?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) (9b9a314) into [main](https://codecov.io/gh/simonw/datasette/commit/d57c347f35bcd8cff15f913da851b4b8eb030867?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) (d57c347) will **increase** coverage by `0.00%`.\n> The diff coverage is `100.00%`.\n\n```diff\n@@ Coverage Diff @@\n## main #1717 +/- ##\n=======================================\n Coverage 91.75% 91.75% \n=======================================\n Files 34 34 \n Lines 4574 4575 +1 \n=======================================\n+ Hits 4197 4198 +1 \n Misses 377 377 \n```\n\n\n| [Impacted Files](https://codecov.io/gh/simonw/datasette/pull/1717?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) | Coverage \u0394 | |\n|---|---|---|\n| [datasette/publish/cloudrun.py](https://codecov.io/gh/simonw/datasette/pull/1717/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison#diff-ZGF0YXNldHRlL3B1Ymxpc2gvY2xvdWRydW4ucHk=) | `97.05% <100.00%> (+0.04%)` | :arrow_up: |\n\n------\n\n[Continue to review full report at Codecov](https://codecov.io/gh/simonw/datasette/pull/1717?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison).\n> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison)\n> `\u0394 = absolute (impact)`, `\u00f8 = not affected`, `? = missing data`\n> Powered by [Codecov](https://codecov.io/gh/simonw/datasette/pull/1717?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison). Last update [d57c347...9b9a314](https://codecov.io/gh/simonw/datasette/pull/1717?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison).\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1213281044, "label": "Add timeout option to Cloudrun build"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1715#issuecomment-1106989581", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1715", "id": 1106989581, "node_id": "IC_kwDOBm6k_c5B-1IN", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-22T23:03:29Z", "updated_at": "2022-04-22T23:03:29Z", "author_association": "OWNER", "body": "I'm having second thoughts about injecting `request` - might be better to have the view function pull the relevant pieces out of the request before triggering the rest of the resolution.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1212823665, "label": "Refactor TableView to use asyncinject"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1715#issuecomment-1106947168", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1715", "id": 1106947168, "node_id": "IC_kwDOBm6k_c5B-qxg", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-22T22:25:57Z", "updated_at": "2022-04-22T22:26:06Z", "author_association": "OWNER", "body": "```python\r\nasync def database(request: Request, datasette: Datasette) -> Database:\r\n database_route = tilde_decode(request.url_vars[\"database\"])\r\n try:\r\n return datasette.get_database(route=database_route)\r\n except KeyError:\r\n raise NotFound(\"Database not found: {}\".format(database_route))\r\n\r\nasync def table_name(request: Request) -> str:\r\n return tilde_decode(request.url_vars[\"table\"])\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1212823665, "label": "Refactor TableView to use asyncinject"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1715#issuecomment-1106945876", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1715", "id": 1106945876, "node_id": "IC_kwDOBm6k_c5B-qdU", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-22T22:24:29Z", "updated_at": "2022-04-22T22:24:29Z", "author_association": "OWNER", "body": "Looking at the start of `TableView.data()`:\r\n\r\nhttps://github.com/simonw/datasette/blob/d57c347f35bcd8cff15f913da851b4b8eb030867/datasette/views/table.py#L333-L346\r\n\r\nI'm going to resolve `table_name` and `database` from the URL - `table_name` will be a string, `database` will be the DB object returned by `datasette.get_database()`. Then those can be passed in separately too.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1212823665, "label": "Refactor TableView to use asyncinject"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1716#issuecomment-1106923258", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1716", "id": 1106923258, "node_id": "IC_kwDOBm6k_c5B-k76", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-22T22:02:07Z", "updated_at": "2022-04-22T22:02:07Z", "author_association": "OWNER", "body": "https://github.com/simonw/datasette/blame/main/datasette/views/base.py\r\n\r\n\"image\"\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1212838949, "label": "Configure git blame to ignore Black commit"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1715#issuecomment-1106908642", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1715", "id": 1106908642, "node_id": "IC_kwDOBm6k_c5B-hXi", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-22T21:47:55Z", "updated_at": "2022-04-22T21:47:55Z", "author_association": "OWNER", "body": "I need a `asyncio.Registry` with functions registered to perform the role of the table view.\r\n\r\nSomething like this perhaps:\r\n```python\r\ndef table_html_context(facet_results, query, datasette, rows):\r\n return {...}\r\n```\r\nThat then gets called like this:\r\n```python\r\nasync def view(request):\r\n registry = Registry(facet_results, query, datasette, rows)\r\n context = await registry.resolve(table_html, request=request, datasette=datasette)\r\n return Reponse.html(await datasette.render(\"table.html\", context)\r\n```\r\nIt's also interesting to start thinking about this from a Python client library point of view. If I'm writing code outside of the HTTP request cycle, what would it look like?\r\n\r\nOne thing I could do: break out is the code that turns a request into a list of pairs extracted from the request - this code here: https://github.com/simonw/datasette/blob/8338c66a57502ef27c3d7afb2527fbc0663b2570/datasette/views/table.py#L442-L449\r\n\r\nI could turn that into a typed dependency injection function like this:\r\n\r\n```python\r\ndef filter_args(request: Request) -> List[Tuple[str, str]]:\r\n # Arguments that start with _ and don't contain a __ are\r\n # special - things like ?_search= - and should not be\r\n # treated as filters.\r\n filter_args = []\r\n for key in request.args:\r\n if not (key.startswith(\"_\") and \"__\" not in key):\r\n for v in request.args.getlist(key):\r\n filter_args.append((key, v))\r\n return filter_args\r\n```\r\nThen I can either pass a `request` into a `.resolve()` call, or I can instead skip that function by passing:\r\n\r\n```python\r\noutput = registry.resolve(table_context, filter_args=[(\"foo\", \"bar\")])\r\n```\r\nI do need to think about where plugins get executed in all of this.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1212823665, "label": "Refactor TableView to use asyncinject"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1101#issuecomment-1105642187", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1101", "id": 1105642187, "node_id": "IC_kwDOBm6k_c5B5sLL", "user": {"value": 25778, "label": "eyeseast"}, "created_at": "2022-04-21T18:59:08Z", "updated_at": "2022-04-21T18:59:08Z", "author_association": "CONTRIBUTOR", "body": "Ha! That was your idea (and a good one).\r\n\r\nBut it's probably worth measuring to see what overhead it adds. It did require both passing in the database and making the whole thing `async`. \r\n\r\nJust timing the queries themselves:\r\n\r\n1. [Using `AsGeoJSON(geometry) as geometry`](https://alltheplaces-datasette.fly.dev/alltheplaces?sql=select%0D%0A++id%2C%0D%0A++properties%2C%0D%0A++AsGeoJSON%28geometry%29+as+geometry%2C%0D%0A++spider%0D%0Afrom%0D%0A++places%0D%0Aorder+by%0D%0A++id%0D%0Alimit%0D%0A++1000) takes 10.235 ms\r\n2. [Leaving as binary](https://alltheplaces-datasette.fly.dev/alltheplaces?sql=select%0D%0A++id%2C%0D%0A++properties%2C%0D%0A++geometry%2C%0D%0A++spider%0D%0Afrom%0D%0A++places%0D%0Aorder+by%0D%0A++id%0D%0Alimit%0D%0A++1000) takes 8.63 ms\r\n\r\nLooking at the network panel:\r\n\r\n1. Takes about 200 ms for the `fetch` request\r\n2. Takes about 300 ms\r\n\r\nI'm not sure how best to time the GeoJSON generation, but it would be interesting to check. Maybe I'll write a plugin to add query times to response headers.\r\n\r\nThe other thing to consider with async streaming is that it might be well-suited for a slower response. When I have to get the whole result and send a response in a fixed amount of time, I need the most efficient query possible. If I can hang onto a connection and get things one chunk at a time, maybe it's ok if there's some overhead.\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 749283032, "label": "register_output_renderer() should support streaming data"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1101#issuecomment-1105615625", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1101", "id": 1105615625, "node_id": "IC_kwDOBm6k_c5B5lsJ", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-21T18:31:41Z", "updated_at": "2022-04-21T18:32:22Z", "author_association": "OWNER", "body": "The `datasette-geojson` plugin is actually an interesting case here, because of the way it converts SpatiaLite geometries into GeoJSON: https://github.com/eyeseast/datasette-geojson/blob/602c4477dc7ddadb1c0a156cbcd2ef6688a5921d/datasette_geojson/__init__.py#L61-L66\r\n\r\n```python\r\n\r\n if isinstance(geometry, bytes):\r\n results = await db.execute(\r\n \"SELECT AsGeoJSON(:geometry)\", {\"geometry\": geometry}\r\n )\r\n return geojson.loads(results.single_value())\r\n```\r\nThat actually seems to work really well as-is, but it does worry me a bit that it ends up having to execute an extra `SELECT` query for every single returned row - especially in streaming mode where it might be asked to return 1m rows at once.\r\n\r\nMy PostgreSQL/MySQL engineering brain says that this would be better handled by doing a chunk of these (maybe 100) at once, to avoid the per-query-overhead - but with SQLite that might not be necessary.\r\n\r\nAt any rate, this is one of the reasons I'm interested in \"iterate over this sequence of chunks of 100 rows at a time\" as a potential option here.\r\n\r\nOf course, a better solution would be for `datasette-geojson` to have a way to influence the SQL query before it is executed, adding a `AsGeoJSON(geometry)` clause to it - so that's something I'm open to as well.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 749283032, "label": "register_output_renderer() should support streaming data"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1101#issuecomment-1105608964", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1101", "id": 1105608964, "node_id": "IC_kwDOBm6k_c5B5kEE", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-21T18:26:29Z", "updated_at": "2022-04-21T18:26:29Z", "author_association": "OWNER", "body": "I'm questioning if the mechanisms should be separate at all now - a single response rendering is really just a case of a streaming response that only pulls the first N records from the iterator.\r\n\r\nIt probably needs to be an `async for` iterator, which I've not worked with much before. Good opportunity to learn.\r\n\r\nThis actually gets a fair bit more complicated due to the work I'm doing right now to improve the default JSON API:\r\n\r\n- #1709\r\n\r\nI want to do things like make faceting results optionally available to custom renderers - which is a separate concern from streaming rows.\r\n\r\nI'm going to poke around with a bunch of prototypes and see what sticks.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 749283032, "label": "register_output_renderer() should support streaming data"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1101#issuecomment-1105588651", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1101", "id": 1105588651, "node_id": "IC_kwDOBm6k_c5B5fGr", "user": {"value": 25778, "label": "eyeseast"}, "created_at": "2022-04-21T18:15:39Z", "updated_at": "2022-04-21T18:15:39Z", "author_association": "CONTRIBUTOR", "body": "What if you split rendering and streaming into two things:\r\n\r\n- `render` is a function that returns a response\r\n- `stream` is a function that sends chunks, or yields chunks passed to an ASGI `send` callback\r\n\r\nThat way current plugins still work, and streaming is purely additive. A `stream` function could get a cursor or iterator of rows, instead of a list, so it could more efficiently handle large queries.\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 749283032, "label": "register_output_renderer() should support streaming data"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1101#issuecomment-1105571003", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1101", "id": 1105571003, "node_id": "IC_kwDOBm6k_c5B5ay7", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-21T18:10:38Z", "updated_at": "2022-04-21T18:10:46Z", "author_association": "OWNER", "body": "Maybe the simplest design for this is to add an optional `can_stream` to the contract:\r\n\r\n```python\r\n @hookimpl\r\n def register_output_renderer(datasette):\r\n return {\r\n \"extension\": \"tsv\",\r\n \"render\": render_tsv,\r\n \"can_render\": lambda: True,\r\n \"can_stream\": lambda: True\r\n }\r\n```\r\nWhen streaming, a new parameter could be passed to the render function - maybe `chunks` - which is an iterator/generator over a sequence of chunks of rows.\r\n\r\nOr it could use the existing `rows` parameter but treat that as an iterator?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 749283032, "label": "register_output_renderer() should support streaming data"}, "performed_via_github_app": null} {"html_url": "https://github.com/dogsheep/github-to-sqlite/issues/72#issuecomment-1105474232", "issue_url": "https://api.github.com/repos/dogsheep/github-to-sqlite/issues/72", "id": 1105474232, "node_id": "IC_kwDODFdgUs5B5DK4", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-21T17:02:15Z", "updated_at": "2022-04-21T17:02:15Z", "author_association": "MEMBER", "body": "That's interesting - yeah it looks like the number of pages can be derived from the `Link` header, which is enough information to show a progress bar, probably using Click just to avoid adding another dependency.\r\n\r\nhttps://docs.github.com/en/rest/guides/traversing-with-pagination", "reactions": "{\"total_count\": 1, \"+1\": 1, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1211283427, "label": "feature: display progress bar when downloading multi-page responses"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1574#issuecomment-1105464661", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1574", "id": 1105464661, "node_id": "IC_kwDOBm6k_c5B5A1V", "user": {"value": 208018, "label": "dholth"}, "created_at": "2022-04-21T16:51:24Z", "updated_at": "2022-04-21T16:51:24Z", "author_association": "NONE", "body": "tfw you have more ephemeral storage than upstream bandwidth\r\n\r\n```\r\nFROM python:3.10-slim AS base\r\n\r\nRUN apt update && apt -y install zstd\r\n\r\nENV DATASETTE_SECRET 'sosecret'\r\nRUN --mount=type=cache,target=/root/.cache/pip\r\n pip install -U datasette datasette-pretty-json datasette-graphql\r\n\r\nENV PORT 8080\r\nEXPOSE 8080\r\n\r\nFROM base AS pack\r\n\r\nCOPY . /app\r\nWORKDIR /app\r\n\r\nRUN datasette inspect --inspect-file inspect-data.json\r\nRUN zstd --rm *.db\r\n\r\nFROM base AS unpack\r\n\r\nCOPY --from=pack /app /app\r\nWORKDIR /app\r\n\r\nCMD [\"/bin/bash\", \"-c\", \"shopt -s nullglob && zstd --rm -d *.db.zst && datasette serve --host 0.0.0.0 --cors --inspect-file inspect-data.json --metadata metadata.json --create --port $PORT *.db\"]\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1084193403, "label": "introduce new option for datasette package to use a slim base image"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1713#issuecomment-1103312860", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1713", "id": 1103312860, "node_id": "IC_kwDOBm6k_c5Bwzfc", "user": {"value": 536941, "label": "fgregg"}, "created_at": "2022-04-20T00:52:19Z", "updated_at": "2022-04-20T00:52:19Z", "author_association": "CONTRIBUTOR", "body": "feels related to #1402 ", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1203943272, "label": "Datasette feature for publishing snapshots of query results"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/425#issuecomment-1101594549", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/425", "id": 1101594549, "node_id": "IC_kwDOCGYnMM5BqP-1", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-18T17:36:14Z", "updated_at": "2022-04-18T17:36:14Z", "author_association": "OWNER", "body": "Releated:\r\n- #408", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1203842656, "label": "`sqlite3.NotSupportedError`: deterministic=True requires SQLite 3.8.3 or higher"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1159#issuecomment-1100243987", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1159", "id": 1100243987, "node_id": "IC_kwDOBm6k_c5BlGQT", "user": {"value": 552629, "label": "lovasoa"}, "created_at": "2022-04-15T17:24:43Z", "updated_at": "2022-04-15T17:24:43Z", "author_association": "NONE", "body": "@simonw : do you think this could be merged ?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 774332247, "label": "Improve the display of facets information"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1713#issuecomment-1099540225", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1713", "id": 1099540225, "node_id": "IC_kwDOBm6k_c5BiacB", "user": {"value": 25778, "label": "eyeseast"}, "created_at": "2022-04-14T19:09:57Z", "updated_at": "2022-04-14T19:09:57Z", "author_association": "CONTRIBUTOR", "body": "I wonder if this overlaps with what I outlined in #1605. You could run something like this:\r\n\r\n```sh\r\ndatasette freeze -d exports/\r\naws s3 cp exports/ s3://my-export-bucket/$(date)\r\n```\r\n\r\nAnd maybe that does what you need. Of course, that plugin isn't built yet. But that's the idea.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1203943272, "label": "Datasette feature for publishing snapshots of query results"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1713#issuecomment-1099443468", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1713", "id": 1099443468, "node_id": "IC_kwDOBm6k_c5BiC0M", "user": {"value": 9308268, "label": "rayvoelker"}, "created_at": "2022-04-14T17:26:27Z", "updated_at": "2022-04-14T17:26:27Z", "author_association": "NONE", "body": "What would be an awesome feature as a plugin would be to be able to save a query (and possibly even results) to a github gist. Being able to share results that way would be super fantastic. Possibly even in Jupyter Notebook format (since github and github gists nicely render those)! \r\n\r\nI know there's the handy datasette-saved-queries plugin, but a button that could export stuff out and then even possibly import stuff back in (I'm sort of thinking the way that Google Colab allows you to save to github, and then pull the notebook back in is a really great workflow \r\n![image](https://user-images.githubusercontent.com/9308268/163441612-9ad2649f-c73e-4557-aaf2-e3d0fdc48fbf.png)\r\nhttps://github.com/cincinnatilibrary/collection-analysis/blob/master/reports/colab_datasette_example.ipynb )", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1203943272, "label": "Datasette feature for publishing snapshots of query results"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1713#issuecomment-1098628334", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1713", "id": 1098628334, "node_id": "IC_kwDOBm6k_c5Be7zu", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-14T01:43:00Z", "updated_at": "2022-04-14T01:43:13Z", "author_association": "OWNER", "body": "Current workaround for fast publishing to S3:\r\n\r\n datasette fixtures.db --get /fixtures/facetable.json | \\\r\n s3-credentials put-object my-bucket facetable.json -", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1203943272, "label": "Datasette feature for publishing snapshots of query results"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/421#issuecomment-1098548931", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/421", "id": 1098548931, "node_id": "IC_kwDOCGYnMM5BeobD", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-13T22:41:59Z", "updated_at": "2022-04-13T22:41:59Z", "author_association": "OWNER", "body": "I'm going to close this ticket since it looks like this is a bug in the way the Dockerfile builds Python, but I'm going to ship a fix for that issue I found so the `LD_PRELOAD` workaround above should work OK with the next release of `sqlite-utils`. Thanks for the detailed bug report!", "reactions": "{\"total_count\": 1, \"+1\": 1, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1180427792, "label": "\"Error: near \"(\": syntax error\" when using sqlite-utils indexes CLI"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/424#issuecomment-1098548090", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/424", "id": 1098548090, "node_id": "IC_kwDOCGYnMM5BeoN6", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-13T22:40:15Z", "updated_at": "2022-04-13T22:40:15Z", "author_association": "OWNER", "body": "New error:\r\n```pycon\r\n>>> from sqlite_utils import Database\r\n>>> db = Database(memory=True)\r\n>>> db[\"foo\"].create({})\r\nTraceback (most recent call last):\r\n File \"\", line 1, in \r\n File \"/Users/simon/Dropbox/Development/sqlite-utils/sqlite_utils/db.py\", line 1465, in create\r\n self.db.create_table(\r\n File \"/Users/simon/Dropbox/Development/sqlite-utils/sqlite_utils/db.py\", line 885, in create_table\r\n sql = self.create_table_sql(\r\n File \"/Users/simon/Dropbox/Development/sqlite-utils/sqlite_utils/db.py\", line 771, in create_table_sql\r\n assert columns, \"Tables must have at least one column\"\r\nAssertionError: Tables must have at least one column\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1200866134, "label": "Better error message if you try to create a table with no columns"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/425#issuecomment-1098545390", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/425", "id": 1098545390, "node_id": "IC_kwDOCGYnMM5Benju", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-13T22:34:52Z", "updated_at": "2022-04-13T22:34:52Z", "author_association": "OWNER", "body": "That broke Python 3.7 because it doesn't support `deterministic=True` even being passed:\r\n\r\n> function takes at most 3 arguments (4 given)", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1203842656, "label": "`sqlite3.NotSupportedError`: deterministic=True requires SQLite 3.8.3 or higher"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/425#issuecomment-1098537000", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/425", "id": 1098537000, "node_id": "IC_kwDOCGYnMM5Belgo", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-13T22:18:22Z", "updated_at": "2022-04-13T22:18:22Z", "author_association": "OWNER", "body": "I figured out a workaround in https://github.com/simonw/sqlite-utils/issues/421#issuecomment-1098535531\r\n\r\nThe current `register(fn)` method looks like this: https://github.com/simonw/sqlite-utils/blob/95522ad919f96eb6cc8cd3cd30389b534680c717/sqlite_utils/db.py#L389-L403\r\n\r\nThis alternative implementation worked in the environment where that failed:\r\n\r\n```python\r\n def register(fn):\r\n name = fn.__name__\r\n arity = len(inspect.signature(fn).parameters)\r\n if not replace and (name, arity) in self._registered_functions:\r\n return fn\r\n kwargs = {}\r\n done = False\r\n if deterministic:\r\n # Try this, but fall back if sqlite3.NotSupportedError\r\n try:\r\n self.conn.create_function(name, arity, fn, **dict(kwargs, deterministic=True))\r\n done = True\r\n except sqlite3.NotSupportedError:\r\n pass\r\n if not done:\r\n self.conn.create_function(name, arity, fn, **kwargs)\r\n self._registered_functions.add((name, arity))\r\n return fn\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1203842656, "label": "`sqlite3.NotSupportedError`: deterministic=True requires SQLite 3.8.3 or higher"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/421#issuecomment-1098535531", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/421", "id": 1098535531, "node_id": "IC_kwDOCGYnMM5BelJr", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-13T22:15:48Z", "updated_at": "2022-04-13T22:15:48Z", "author_association": "OWNER", "body": "Trying this alternative implementation of the `register()` method:\r\n\r\n```python\r\n def register(fn):\r\n name = fn.__name__\r\n arity = len(inspect.signature(fn).parameters)\r\n if not replace and (name, arity) in self._registered_functions:\r\n return fn\r\n kwargs = {}\r\n done = False\r\n if deterministic:\r\n # Try this, but fall back if sqlite3.NotSupportedError\r\n try:\r\n self.conn.create_function(name, arity, fn, **dict(kwargs, deterministic=True))\r\n done = True\r\n except sqlite3.NotSupportedError:\r\n pass\r\n if not done:\r\n self.conn.create_function(name, arity, fn, **kwargs)\r\n self._registered_functions.add((name, arity))\r\n return fn\r\n```\r\nWith that fix, the following worked!\r\n```\r\nLD_PRELOAD=./build/sqlite-autoconf-3360000/.libs/libsqlite3.so sqlite-utils indexes /tmp/global.db --table\r\ntable index_name seqno cid name desc coll key\r\n--------- -------------------------- ------- ----- ------- ------ ------ -----\r\ncountries idx_countries_country_name 0 1 country 0 BINARY 1\r\ncountries idx_countries_country_name 1 2 name 0 BINARY 1\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1180427792, "label": "\"Error: near \"(\": syntax error\" when using sqlite-utils indexes CLI"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/421#issuecomment-1098532220", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/421", "id": 1098532220, "node_id": "IC_kwDOCGYnMM5BekV8", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-13T22:09:52Z", "updated_at": "2022-04-13T22:09:52Z", "author_association": "OWNER", "body": "That error is weird - it's not supposed to happen according to this code here: https://github.com/simonw/sqlite-utils/blob/95522ad919f96eb6cc8cd3cd30389b534680c717/sqlite_utils/db.py#L389-L400", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1180427792, "label": "\"Error: near \"(\": syntax error\" when using sqlite-utils indexes CLI"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/421#issuecomment-1098531354", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/421", "id": 1098531354, "node_id": "IC_kwDOCGYnMM5BekIa", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-13T22:08:20Z", "updated_at": "2022-04-13T22:08:20Z", "author_association": "OWNER", "body": "OK I figured out what's going on here. First I added an extra `print(sql)` statement to the `indexes` command to see what SQL it was running:\r\n```\r\n(app-root) sqlite-utils indexes global.db --table\r\n\r\n select\r\n sqlite_master.name as \"table\",\r\n indexes.name as index_name,\r\n xinfo.*\r\n from sqlite_master\r\n join pragma_index_list(sqlite_master.name) indexes\r\n join pragma_index_xinfo(index_name) xinfo\r\n where\r\n sqlite_master.type = 'table'\r\n and xinfo.key = 1\r\nError: near \"(\": syntax error\r\n```\r\nThis made me suspicious that the SQLite version being used here didn't support joining against the `pragma_index_list(...)` table-valued functions in that way. So I checked the version:\r\n```\r\n(app-root) sqlite3\r\nSQLite version 3.36.0 2021-06-18 18:36:39\r\n```\r\nThat version should be fine - it's the one you compiled in the Dockerfile.\r\n\r\nThen I checked the version that `sqlite-utils` itself was using:\r\n```\r\n(app-root) sqlite-utils memory 'select sqlite_version()'\r\n[{\"sqlite_version()\": \"3.7.17\"}]\r\n```\r\nIt's running SQLite 3.7.17!\r\n\r\nSo the problem here is that the Python in that Docker image is running a very old version of SQLite.\r\n\r\nI tried using the trick in https://til.simonwillison.net/sqlite/ld-preload as a workaround, and it almost worked:\r\n\r\n```\r\n(app-root) python3 -c 'import sqlite3; print(sqlite3.connect(\":memory\").execute(\"select sqlite_version()\").fetchone())'\r\n('3.7.17',)\r\n(app-root) LD_PRELOAD=./build/sqlite-autoconf-3360000/.libs/libsqlite3.so python3 -c 'import sqlite3; print(sqlite3.connect(\":memory\").execute(\"select sqlite_version()\").fetchone())'\r\n('3.36.0',)\r\n```\r\nBut when I try to run `sqlite-utils` like that I get an error:\r\n\r\n```\r\n(app-root) LD_PRELOAD=./build/sqlite-autoconf-3360000/.libs/libsqlite3.so sqlite-utils indexes /tmp/global.db \r\n...\r\n File \"/opt/app-root/lib64/python3.8/site-packages/sqlite_utils/cli.py\", line 1624, in query\r\n db.register_fts4_bm25()\r\n File \"/opt/app-root/lib64/python3.8/site-packages/sqlite_utils/db.py\", line 412, in register_fts4_bm25\r\n self.register_function(rank_bm25, deterministic=True)\r\n File \"/opt/app-root/lib64/python3.8/site-packages/sqlite_utils/db.py\", line 408, in register_function\r\n register(fn)\r\n File \"/opt/app-root/lib64/python3.8/site-packages/sqlite_utils/db.py\", line 401, in register\r\n self.conn.create_function(name, arity, fn, **kwargs)\r\nsqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1180427792, "label": "\"Error: near \"(\": syntax error\" when using sqlite-utils indexes CLI"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/421#issuecomment-1098295517", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/421", "id": 1098295517, "node_id": "IC_kwDOCGYnMM5Bdqjd", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-13T17:16:20Z", "updated_at": "2022-04-13T17:16:20Z", "author_association": "OWNER", "body": "Aha! I was able to replicate the bug using your `Dockerfile` - thanks very much for providing that.\r\n```\r\n(app-root) sqlite-utils indexes global.db --table\r\nError: near \"(\": syntax error\r\n```\r\n(That wa sbefore I even ran the `extract` command.)\r\n\r\nTo build your `Dockerfile` I copied it into an empty folder and ran the following:\r\n```\r\nwget https://www.sqlite.org/2021/sqlite-autoconf-3360000.tar.gz\r\ndocker build . -t centos-sqlite-utils\r\ndocker run -it centos-sqlite-utils /bin/bash\r\n```\r\nThis gave me a shell in which I could replicate the bug.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1180427792, "label": "\"Error: near \"(\": syntax error\" when using sqlite-utils indexes CLI"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/421#issuecomment-1098288158", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/421", "id": 1098288158, "node_id": "IC_kwDOCGYnMM5Bdowe", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-13T17:07:53Z", "updated_at": "2022-04-13T17:07:53Z", "author_association": "OWNER", "body": "I can't replicate the bug I'm afraid:\r\n```\r\n% wget \"https://github.com/wri/global-power-plant-database/blob/232a6666/output_database/global_power_plant_database.csv?raw=true\" \r\n...\r\n2022-04-13 10:06:29 (8.97 MB/s) - \u2018global_power_plant_database.csv?raw=true\u2019 saved [8856038/8856038]\r\n% sqlite-utils insert global.db power_plants \\ \r\n 'global_power_plant_database.csv?raw=true' --csv\r\n [------------------------------------] 0%\r\n [###################################-] 99% 00:00:00%\r\n% sqlite-utils indexes global.db --table \r\ntable index_name seqno cid name desc coll key\r\n------- ------------ ------- ----- ------ ------ ------ -----\r\n% sqlite-utils extract global.db power_plants country country_long \\\r\n --table countries \\\r\n --fk-column country_id \\\r\n --rename country_long name\r\n% sqlite-utils indexes global.db --table \r\ntable index_name seqno cid name desc coll key\r\n--------- -------------------------- ------- ----- ------- ------ ------ -----\r\ncountries idx_countries_country_name 0 1 country 0 BINARY 1\r\ncountries idx_countries_country_name 1 2 name 0 BINARY 1\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1180427792, "label": "\"Error: near \"(\": syntax error\" when using sqlite-utils indexes CLI"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1712#issuecomment-1097115034", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1712", "id": 1097115034, "node_id": "IC_kwDOBm6k_c5BZKWa", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-12T19:12:21Z", "updated_at": "2022-04-12T19:12:21Z", "author_association": "OWNER", "body": "Got a TIL out of this too: https://til.simonwillison.net/spatialite/gunion-to-combine-geometries", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1202227104, "label": "Make \"\" easier to read"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1712#issuecomment-1097076622", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1712", "id": 1097076622, "node_id": "IC_kwDOBm6k_c5BZA-O", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-12T18:42:04Z", "updated_at": "2022-04-12T18:42:04Z", "author_association": "OWNER", "body": "I'm not going to show the tooltip if the formatted number is in bytes.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1202227104, "label": "Make \"\" easier to read"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1712#issuecomment-1097068474", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1712", "id": 1097068474, "node_id": "IC_kwDOBm6k_c5BY--6", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-12T18:38:18Z", "updated_at": "2022-04-12T18:38:18Z", "author_association": "OWNER", "body": "\"image\"\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1202227104, "label": "Make \"\" easier to read"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1708#issuecomment-1095687566", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1708", "id": 1095687566, "node_id": "IC_kwDOBm6k_c5BTt2O", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-11T23:24:30Z", "updated_at": "2022-04-11T23:24:30Z", "author_association": "OWNER", "body": "## Redesigned template context\r\n\r\n**Warning:** if you use any custom templates with your Datasette instance they are likely to break when you upgrade to 1.0.\r\n\r\nThe template context has been redesigned to be based on the documented JSON API. This means that the template context can be considered stable going forward, so any custom templates you implement should continue to work when you upgrade Datasette in the future.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1200649124, "label": "Datasette 1.0 alpha upcoming release notes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1705#issuecomment-1095673947", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1705", "id": 1095673947, "node_id": "IC_kwDOBm6k_c5BTqhb", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-11T23:03:49Z", "updated_at": "2022-04-11T23:03:49Z", "author_association": "OWNER", "body": "I'll also encourage testing against both Datasette 0.x and Datasette 1.0 using a GitHub Actions matrix.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1197926598, "label": "How to upgrade your plugin for 1.0 documentation"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1710#issuecomment-1095673670", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1710", "id": 1095673670, "node_id": "IC_kwDOBm6k_c5BTqdG", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-11T23:03:25Z", "updated_at": "2022-04-11T23:03:25Z", "author_association": "OWNER", "body": "Dupe of:\r\n- #1705", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1200649889, "label": "Guide for plugin authors to upgrade their plugins for 1.0"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1709#issuecomment-1095671940", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1709", "id": 1095671940, "node_id": "IC_kwDOBm6k_c5BTqCE", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-11T23:00:39Z", "updated_at": "2022-04-11T23:01:41Z", "author_association": "OWNER", "body": "- #262\r\n- #782 \r\n- #1509", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1200649502, "label": "Redesigned JSON API with ?_extra= parameters"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1711#issuecomment-1095672127", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1711", "id": 1095672127, "node_id": "IC_kwDOBm6k_c5BTqE_", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-11T23:00:58Z", "updated_at": "2022-04-11T23:00:58Z", "author_association": "OWNER", "body": "- #1510", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1200650491, "label": "Template context powered entirely by the JSON API format"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1707#issuecomment-1095277937", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1707", "id": 1095277937, "node_id": "IC_kwDOBm6k_c5BSJ1x", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-11T16:32:31Z", "updated_at": "2022-04-11T16:33:00Z", "author_association": "OWNER", "body": "That's a really interesting idea!\r\n\r\nThat page is one of the least developed at the moment. There's plenty of room for it to grow new useful features.\r\n\r\nI like this suggestion because it feels like a good opportunity to introduce some unobtrusive JavaScript. Could use a details/summary element that uses `fetch()` to load in the extra data for example.\r\n\r\nCould even do something with the `` Web Component here... https://github.com/simonw/datasette-table", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1200224939, "label": "[feature] expanded detail page"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1699#issuecomment-1094453751", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1699", "id": 1094453751, "node_id": "IC_kwDOBm6k_c5BPAn3", "user": {"value": 25778, "label": "eyeseast"}, "created_at": "2022-04-11T01:32:12Z", "updated_at": "2022-04-11T01:32:12Z", "author_association": "CONTRIBUTOR", "body": "Was looking through old issues and realized a bunch of this got discussed in #1101 (including by me!), so sorry to rehash all this. Happy to help with whatever piece of it I can. Would be very excited to be able to use format plugins with exports.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1193090967, "label": "Proposal: datasette query"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1706#issuecomment-1094152642", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1706", "id": 1094152642, "node_id": "IC_kwDOBm6k_c5BN3HC", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-10T01:11:54Z", "updated_at": "2022-04-10T01:11:54Z", "author_association": "OWNER", "body": "This relates to this much larger vision:\r\n- #417 ", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1198822563, "label": "[feature] immutable mode for a directory, not just individual sqlite file"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1706#issuecomment-1094152173", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1706", "id": 1094152173, "node_id": "IC_kwDOBm6k_c5BN2_t", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-10T01:08:50Z", "updated_at": "2022-04-10T01:08:50Z", "author_association": "OWNER", "body": "This is a good idea - it matches the way `datasette .` works for mutable database files already.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1198822563, "label": "[feature] immutable mode for a directory, not just individual sqlite file"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1693#issuecomment-1093454899", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1693", "id": 1093454899, "node_id": "IC_kwDOBm6k_c5BLMwz", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-08T23:07:04Z", "updated_at": "2022-04-08T23:07:04Z", "author_association": "OWNER", "body": "Tests failed here due to this issue:\r\n- https://github.com/psf/black/pull/2987\r\n\r\nA future Black release should fix that.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1184850337, "label": "Bump black from 22.1.0 to 22.3.0"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1703#issuecomment-1092850719", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1703", "id": 1092850719, "node_id": "IC_kwDOBm6k_c5BI5Qf", "user": {"value": 22429695, "label": "codecov[bot]"}, "created_at": "2022-04-08T13:18:04Z", "updated_at": "2022-04-08T13:18:04Z", "author_association": "NONE", "body": "# [Codecov](https://codecov.io/gh/simonw/datasette/pull/1703?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) Report\n> Merging [#1703](https://codecov.io/gh/simonw/datasette/pull/1703?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) (73aabe6) into [main](https://codecov.io/gh/simonw/datasette/commit/90d1be9952db9aaddc21a536e4d00a8de44765d7?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) (90d1be9) will **not change** coverage.\n> The diff coverage is `n/a`.\n\n```diff\n@@ Coverage Diff @@\n## main #1703 +/- ##\n=======================================\n Coverage 91.75% 91.75% \n=======================================\n Files 34 34 \n Lines 4573 4573 \n=======================================\n Hits 4196 4196 \n Misses 377 377 \n```\n\n\n\n------\n\n[Continue to review full report at Codecov](https://codecov.io/gh/simonw/datasette/pull/1703?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison).\n> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison)\n> `\u0394 = absolute (impact)`, `\u00f8 = not affected`, `? = missing data`\n> Powered by [Codecov](https://codecov.io/gh/simonw/datasette/pull/1703?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison). Last update [90d1be9...73aabe6](https://codecov.io/gh/simonw/datasette/pull/1703?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison).\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1197298420, "label": "Update beautifulsoup4 requirement from <4.11.0,>=4.8.1 to >=4.8.1,<4.12.0"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1699#issuecomment-1092386254", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1699", "id": 1092386254, "node_id": "IC_kwDOBm6k_c5BHH3O", "user": {"value": 25778, "label": "eyeseast"}, "created_at": "2022-04-08T02:39:25Z", "updated_at": "2022-04-08T02:39:25Z", "author_association": "CONTRIBUTOR", "body": "And just to think this through a little more, here's what `stream_geojson` might look like:\r\n\r\n```python\r\nasync def stream_geojson(datasette, columns, rows, database, stream):\r\n db = datasette.get_database(database)\r\n for row in rows:\r\n feature = await row_to_geojson(row, db)\r\n stream.write(feature + \"\\n\") # just assuming newline mode for now\r\n```\r\n\r\nAlternately, that could be an async generator, like this:\r\n\r\n```python\r\nasync def stream_geojson(datasette, columns, rows, database):\r\n db = datasette.get_database(database)\r\n for row in rows:\r\n feature = await row_to_geojson(row, db)\r\n yield feature\r\n```\r\n\r\nNot sure which makes more sense, but I think this pattern would open up a lot of possibility. If you had your [stream_indented_json](https://til.simonwillison.net/python/output-json-array-streaming) function, you could do `yield from stream_indented_json(rows, 2)` and be one your way.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1193090967, "label": "Proposal: datasette query"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1699#issuecomment-1092370880", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1699", "id": 1092370880, "node_id": "IC_kwDOBm6k_c5BHEHA", "user": {"value": 25778, "label": "eyeseast"}, "created_at": "2022-04-08T02:07:40Z", "updated_at": "2022-04-08T02:07:40Z", "author_association": "CONTRIBUTOR", "body": "So maybe `render_output_render` returns something like this:\r\n\r\n```python\r\n@hookimpl\r\ndef register_output_renderer(datasette):\r\n return {\r\n \"extension\": \"geojson\",\r\n \"render\": render_geojson,\r\n \"stream\": stream_geojson,\r\n \"can_render\": can_render_geojson,\r\n }\r\n```\r\n\r\nAnd stream gets an iterator, instead of a list of rows, so it can efficiently handle large queries. Maybe it also gets passed a destination stream, or it returns an iterator. I'm not sure what makes more sense. Either way, that might cover both CLI exports and streaming responses.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1193090967, "label": "Proposal: datasette query"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1699#issuecomment-1092361727", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1699", "id": 1092361727, "node_id": "IC_kwDOBm6k_c5BHB3_", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-08T01:47:43Z", "updated_at": "2022-04-08T01:47:43Z", "author_association": "OWNER", "body": "A render mode for that plugin hook that writes to a stream is exactly what I have in mind:\r\n- #1062 ", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1193090967, "label": "Proposal: datasette query"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1699#issuecomment-1092357672", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1699", "id": 1092357672, "node_id": "IC_kwDOBm6k_c5BHA4o", "user": {"value": 25778, "label": "eyeseast"}, "created_at": "2022-04-08T01:39:40Z", "updated_at": "2022-04-08T01:39:40Z", "author_association": "CONTRIBUTOR", "body": "> My best thought on how to differentiate them so far is plugins: if Datasette plugins that provide alternative outputs - like .geojson and .yml and suchlike - also work for the datasette query command that would make a lot of sense to me.\r\n\r\nThat's my thinking, too. It's really the thing I've been wanting since writing `datasette-geojson`, since I'm always exporting with `datasette --get`. The workflow I'm always looking for is something like this:\r\n\r\n```sh\r\ncd alltheplaces-datasette\r\ndatasette query dunkin_in_suffolk -f geojson -o dunkin_in_suffolk.geojson\r\n```\r\n\r\nI think this probably needs either a new plugin hook separate from `register_output_renderer` or a way to use that without going through the HTTP stack. Or maybe a render mode that writes to a stream instead of a response. Maybe there's a new key in the dictionary that `register_output_renderer` returns that handles CLI exports.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1193090967, "label": "Proposal: datasette query"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1699#issuecomment-1092321966", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1699", "id": 1092321966, "node_id": "IC_kwDOBm6k_c5BG4Ku", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-08T00:20:32Z", "updated_at": "2022-04-08T00:20:56Z", "author_association": "OWNER", "body": "If we do this I'm keen to have it be more than just an alternative to the existing `sqlite-utils` command - especially since if I add `sqlite-utils` as a dependency of Datasette in the future that command will be installed as part of `pip install datasette` anyway.\r\n\r\nMy best thought on how to differentiate them so far is plugins: if Datasette plugins that provide alternative outputs - like `.geojson` and `.yml` and suchlike - also work for the `datasette query` command that would make a lot of sense to me.\r\n\r\nOne way that could work: a `--fmt geojson` option to this command which uses the plugin that was registered for the specified extension.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1193090967, "label": "Proposal: datasette query"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1549#issuecomment-1087428593", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1549", "id": 1087428593, "node_id": "IC_kwDOBm6k_c5A0Nfx", "user": {"value": 536941, "label": "fgregg"}, "created_at": "2022-04-04T11:17:13Z", "updated_at": "2022-04-04T11:17:13Z", "author_association": "CONTRIBUTOR", "body": "another way to get the behavior of downloading the file is to use the download attribute of the anchor tag\r\n\r\nhttps://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1077620955, "label": "Redesign CSV export to improve usability"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1698#issuecomment-1086784547", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1698", "id": 1086784547, "node_id": "IC_kwDOBm6k_c5AxwQj", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-04-03T06:10:24Z", "updated_at": "2022-04-03T06:10:24Z", "author_association": "OWNER", "body": "Warning added here: https://docs.datasette.io/en/latest/publish.html#publishing-to-google-cloud-run", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1190828163, "label": "Add a warning about bots and Cloud Run"}, "performed_via_github_app": null}