{"html_url": "https://github.com/simonw/sqlite-utils/issues/285#issuecomment-864418795", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/285", "id": 864418795, "node_id": "MDEyOklzc3VlQ29tbWVudDg2NDQxODc5NQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-06-19T15:11:05Z", "updated_at": "2021-06-19T15:11:14Z", "author_association": "OWNER", "body": "Actually I'm going to go with `use_rowid` instead - because the table doesn't inherently use a rowid itself, but you should use one if you want to query it in a way that gives you back a primary key.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 925410305, "label": "Introspection property for telling if a table is a rowid table"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/285#issuecomment-864418188", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/285", "id": 864418188, "node_id": "MDEyOklzc3VlQ29tbWVudDg2NDQxODE4OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-06-19T15:05:53Z", "updated_at": "2021-06-19T15:05:53Z", "author_association": "OWNER", "body": "```python\r\n @property\r\n def uses_rowid(self):\r\n return not any(column for column in self.columns if column.is_pk)\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 925410305, "label": "Introspection property for telling if a table is a rowid table"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/285#issuecomment-864417808", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/285", "id": 864417808, "node_id": "MDEyOklzc3VlQ29tbWVudDg2NDQxNzgwOA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-06-19T15:03:00Z", "updated_at": "2021-06-19T15:03:00Z", "author_association": "OWNER", "body": "I think I like `table.uses_rowid` best - it reads well.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 925410305, "label": "Introspection property for telling if a table is a rowid table"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/285#issuecomment-864417765", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/285", "id": 864417765, "node_id": "MDEyOklzc3VlQ29tbWVudDg2NDQxNzc2NQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-06-19T15:02:42Z", "updated_at": "2021-06-19T15:02:42Z", "author_association": "OWNER", "body": "Some options:\r\n\r\n- `table.rowid_only`\r\n- `table.rowid_as_pk`\r\n- `table.no_pks`\r\n- `table.no_pk`\r\n- `table.uses_rowid`\r\n- `table.use_rowid`", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 925410305, "label": "Introspection property for telling if a table is a rowid table"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/285#issuecomment-864417493", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/285", "id": 864417493, "node_id": "MDEyOklzc3VlQ29tbWVudDg2NDQxNzQ5Mw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-06-19T15:00:43Z", "updated_at": "2021-06-19T15:00:43Z", "author_association": "OWNER", "body": "I have to be careful about the language I use here. Here's the official definition: https://www.sqlite.org/rowidtable.html\r\n\r\n> A \"rowid table\" is any table in an SQLite schema that\r\n> \r\n> - is *not* a [virtual table](https://www.sqlite.org/vtab.html), and\r\n> - is *not* a [WITHOUT ROWID](https://www.sqlite.org/withoutrowid.html) table.\r\n> \r\n> Most tables in a typical SQLite database schema are rowid tables.\r\n> \r\n> Rowid tables are distinguished by the fact that they all have a unique, non-NULL, signed 64-bit integer [rowid](https://www.sqlite.org/lang_createtable.html#rowid) that is used as the access key for the data in the underlying [B-tree](https://www.sqlite.org/fileformat2.html#btree) storage engine.\r\n\r\nSo it's not correct to call a table a \"rowid table\" only if it is missing its own primary keys.\r\n\r\nMaybe `table.has_rowid` is the right language to use here? No, that's no good - because tables with their own primary keys usually also have a rowid.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 925410305, "label": "Introspection property for telling if a table is a rowid table"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/285#issuecomment-864417133", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/285", "id": 864417133, "node_id": "MDEyOklzc3VlQ29tbWVudDg2NDQxNzEzMw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-06-19T14:57:36Z", "updated_at": "2021-06-19T14:57:36Z", "author_association": "OWNER", "body": "So the logic is:\r\n```python\r\n[column.name for column in self.columns if column.is_pk]\r\n```\r\nI need to decide on a property name. Existing names are documented here: https://sqlite-utils.datasette.io/en/stable/python-api.html#introspection", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 925410305, "label": "Introspection property for telling if a table is a rowid table"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/285#issuecomment-864417031", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/285", "id": 864417031, "node_id": "MDEyOklzc3VlQ29tbWVudDg2NDQxNzAzMQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-06-19T14:56:45Z", "updated_at": "2021-06-19T14:56:45Z", "author_association": "OWNER", "body": "```pycon\r\n>>> db = sqlite_utils.Database(memory=True)\r\n>>> db[\"rowid_table\"].insert({\"name\": \"Cleo\"})\r\n\r\n>>> db[\"regular_table\"].insert({\"id\": 1, \"name\": \"Cleo\"}, pk=\"id\")\r\n
\r\n>>> db[\"rowid_table\"].pks\r\n['rowid']\r\n>>> db[\"regular_table\"].pks\r\n['id']\r\n```\r\nBut that's because the `.pks` property hides the difference: https://github.com/simonw/sqlite-utils/blob/dc94f4bb8cfe922bb2f9c89f8f0f29092ea63133/sqlite_utils/db.py#L805-L810\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 925410305, "label": "Introspection property for telling if a table is a rowid table"}, "performed_via_github_app": null}