{"html_url": "https://github.com/simonw/datasette/issues/685#issuecomment-625890190", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/685", "id": 625890190, "node_id": "MDEyOklzc3VlQ29tbWVudDYyNTg5MDE5MA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-05-08T16:09:44Z", "updated_at": "2020-05-08T16:09:56Z", "author_association": "OWNER", "body": "Re-opening this ticket because I forgot to document `execute_fn()` (the old `execute_against_connection_in_thread()` method).", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 570309546, "label": "Document (and reconsider design of) Database.execute() and Database.execute_against_connection_in_thread()"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/685#issuecomment-625889673", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/685", "id": 625889673, "node_id": "MDEyOklzc3VlQ29tbWVudDYyNTg4OTY3Mw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-05-08T16:08:40Z", "updated_at": "2020-05-08T16:08:40Z", "author_association": "OWNER", "body": "I'm going to ship a release with just this change purely so I can start depending on it from my in-development https://github.com/simonw/datasette-media plugin.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 570309546, "label": "Document (and reconsider design of) Database.execute() and Database.execute_against_connection_in_thread()"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/685#issuecomment-625889303", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/685", "id": 625889303, "node_id": "MDEyOklzc3VlQ29tbWVudDYyNTg4OTMwMw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-05-08T16:07:55Z", "updated_at": "2020-05-08T16:07:55Z", "author_association": "OWNER", "body": "New documentation is live here: https://datasette.readthedocs.io/en/latest/internals.html#database-class", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 570309546, "label": "Document (and reconsider design of) Database.execute() and Database.execute_against_connection_in_thread()"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/685#issuecomment-625887196", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/685", "id": 625887196, "node_id": "MDEyOklzc3VlQ29tbWVudDYyNTg4NzE5Ng==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-05-08T16:03:16Z", "updated_at": "2020-05-08T16:03:16Z", "author_association": "OWNER", "body": "[ Fun aside: I implemented and shipped this entire branch in my browser using the beta of GitHub's new [Codespaces](https://github.com/features/codespaces) ]", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 570309546, "label": "Document (and reconsider design of) Database.execute() and Database.execute_against_connection_in_thread()"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/685#issuecomment-625868416", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/685", "id": 625868416, "node_id": "MDEyOklzc3VlQ29tbWVudDYyNTg2ODQxNg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-05-08T15:23:04Z", "updated_at": "2020-05-08T15:23:04Z", "author_association": "OWNER", "body": "I'll move the code into `datasette/database.py`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 570309546, "label": "Document (and reconsider design of) Database.execute() and Database.execute_against_connection_in_thread()"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/685#issuecomment-625866419", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/685", "id": 625866419, "node_id": "MDEyOklzc3VlQ29tbWVudDYyNTg2NjQxOQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-05-08T15:18:55Z", "updated_at": "2020-05-08T15:18:55Z", "author_association": "OWNER", "body": "This code should live somewhere other than `datasette/utils/__init__.py`. Especially the exceptions, since calling code needs to be able to sensibly import them.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 570309546, "label": "Document (and reconsider design of) Database.execute() and Database.execute_against_connection_in_thread()"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/685#issuecomment-625865434", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/685", "id": 625865434, "node_id": "MDEyOklzc3VlQ29tbWVudDYyNTg2NTQzNA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-05-08T15:16:43Z", "updated_at": "2020-05-08T15:16:43Z", "author_association": "OWNER", "body": "Documentation for improved design: https://github.com/simonw/datasette/pull/763/files#diff-87703da03a02e0f8dae01f39abd6250f", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 570309546, "label": "Document (and reconsider design of) Database.execute() and Database.execute_against_connection_in_thread()"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/685#issuecomment-625862578", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/685", "id": 625862578, "node_id": "MDEyOklzc3VlQ29tbWVudDYyNTg2MjU3OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-05-08T15:10:16Z", "updated_at": "2020-05-08T15:10:16Z", "author_association": "OWNER", "body": "I'm not going to do ``.last()`` because it could be confusing if truncation has come into play.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 570309546, "label": "Document (and reconsider design of) Database.execute() and Database.execute_against_connection_in_thread()"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/685#issuecomment-625850152", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/685", "id": 625850152, "node_id": "MDEyOklzc3VlQ29tbWVudDYyNTg1MDE1Mg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-05-08T14:44:37Z", "updated_at": "2020-05-08T14:44:37Z", "author_association": "OWNER", "body": "I'll write the API documentation first, in a branch.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 570309546, "label": "Document (and reconsider design of) Database.execute() and Database.execute_against_connection_in_thread()"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/685#issuecomment-625849497", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/685", "id": 625849497, "node_id": "MDEyOklzc3VlQ29tbWVudDYyNTg0OTQ5Nw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-05-08T14:43:13Z", "updated_at": "2020-05-08T14:43:13Z", "author_association": "OWNER", "body": "I'm going to add `.first()` and `.last()` methods too. These will return the first or last row, or `None` if the results are empty (rather than raising an `IndexError`).", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 570309546, "label": "Document (and reconsider design of) Database.execute() and Database.execute_against_connection_in_thread()"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/685#issuecomment-625841397", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/685", "id": 625841397, "node_id": "MDEyOklzc3VlQ29tbWVudDYyNTg0MTM5Nw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-05-08T14:25:56Z", "updated_at": "2020-05-08T14:27:15Z", "author_association": "OWNER", "body": "Maybe all I really want here is to add length and access-by-index methods to the Results class? So I don't have to do `results.rows[0][0]` to get at a single returned value.\r\n\r\nAlso how about a `results.single_value()` method which returns a value only if there is a single row with a single column, otherwise raises an exception?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 570309546, "label": "Document (and reconsider design of) Database.execute() and Database.execute_against_connection_in_thread()"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/685#issuecomment-625839046", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/685", "id": 625839046, "node_id": "MDEyOklzc3VlQ29tbWVudDYyNTgzOTA0Ng==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-05-08T14:20:43Z", "updated_at": "2020-05-08T14:25:05Z", "author_association": "OWNER", "body": "The API design for the `.execute()` function is actually fine, I think it's more the API of the returned `Results` object that I want to improve.\r\n\r\nThat object encapsulates the returned data, the named columns and whether or not the result was truncated.\r\n\r\n return Results(rows, truncated, cursor.description)\r\n\r\nThe `rows` argument comes from either `rows = cursor.fetchmany(max_returned_rows + 1)` or `rows = cursor.fetchall()`. It's a Python list of `sqlite3.Row` objects.\r\n\r\nHere's the current class implementation:\r\n\r\nhttps://github.com/simonw/datasette/blob/0784f2ef9d3ff6dd9df05f54cb51de29a6d11764/datasette/utils/__init__.py#L54-L68", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 570309546, "label": "Document (and reconsider design of) Database.execute() and Database.execute_against_connection_in_thread()"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/685#issuecomment-625817999", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/685", "id": 625817999, "node_id": "MDEyOklzc3VlQ29tbWVudDYyNTgxNzk5OQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-05-08T13:33:23Z", "updated_at": "2020-05-08T13:33:23Z", "author_association": "OWNER", "body": "I'm going to rename `execute_against_connection_in_thread()` to just `execute_fn()`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 570309546, "label": "Document (and reconsider design of) Database.execute() and Database.execute_against_connection_in_thread()"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/685#issuecomment-625603221", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/685", "id": 625603221, "node_id": "MDEyOklzc3VlQ29tbWVudDYyNTYwMzIyMQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-05-08T03:00:23Z", "updated_at": "2020-05-08T03:00:23Z", "author_association": "OWNER", "body": "Working with this in https://github.com/simonw/datasette-media/issues/2 made me really want to redesign this API: https://github.com/simonw/datasette-media/commit/be23ec3d05900b69a3d47bc1e0dd056c333125f4", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 570309546, "label": "Document (and reconsider design of) Database.execute() and Database.execute_against_connection_in_thread()"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/685#issuecomment-590682210", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/685", "id": 590682210, "node_id": "MDEyOklzc3VlQ29tbWVudDU5MDY4MjIxMA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-02-25T04:50:53Z", "updated_at": "2020-02-25T04:50:53Z", "author_association": "OWNER", "body": "Current implementations:\r\n\r\nhttps://github.com/simonw/datasette/blob/a093c5f79fa034a97d2ad8b606745dd3b80365af/datasette/database.py#L103-L168\r\n\r\nAt the very least the method name `execute_against_connection_in_thread()` should be updated to something that's more similar to the new (and documented) `.execute_write_fn()` method.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 570309546, "label": "Document (and reconsider design of) Database.execute() and Database.execute_against_connection_in_thread()"}, "performed_via_github_app": null}