{"html_url": "https://github.com/simonw/datasette/issues/420#issuecomment-477633354", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/420", "id": 477633354, "node_id": "MDEyOklzc3VlQ29tbWVudDQ3NzYzMzM1NA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-03-28T15:01:37Z", "updated_at": "2019-03-28T15:01:37Z", "author_association": "OWNER", "body": "I started looking at how I would implement `table_exists()` with a direct call that uses `sqlite-utils` to see if a table exists.\r\n\r\nhttps://github.com/simonw/datasette/blob/82fec6048148b58748040a7e2caa163387e982a3/datasette/app.py#L303-L304\r\n\r\n`sqlite-utils` needs access to the database connection - but the database connection itself is currently only available in code that runs in a thread inside the `.execute()` method:\r\n\r\nhttps://github.com/simonw/datasette/blob/82fec6048148b58748040a7e2caa163387e982a3/datasette/app.py#L413-L426\r\n\r\nSo I'm going to need to refactor this a bit. I think I need a way to say \"here is a function which needs access to the connection object for database named X - run that function in a thread, give it access to that connection and then give me back the 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": 421971339, "label": "Fix all the places that currently use .inspect() data"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/420#issuecomment-477636768", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/420", "id": 477636768, "node_id": "MDEyOklzc3VlQ29tbWVudDQ3NzYzNjc2OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-03-28T15:09:27Z", "updated_at": "2019-03-28T15:09:27Z", "author_association": "OWNER", "body": "Even more tricky: `table_exists()` is currently a synchronous function. If it's going to be executing a SQL query it needs to become an async function.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 421971339, "label": "Fix all the places that currently use .inspect() data"}, "performed_via_github_app": null}