{"html_url": "https://github.com/simonw/sqlite-utils/issues/49#issuecomment-514509307", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/49", "id": 514509307, "node_id": "MDEyOklzc3VlQ29tbWVudDUxNDUwOTMwNw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-07-24T07:09:43Z", "updated_at": "2019-07-24T07:10:21Z", "author_association": "OWNER", "body": "This syntax should be shared with #42 as much as possible.\r\n\r\nMaybe something based on a namedtuple would work, since those are already used in the library.\r\n\r\n```python\r\nworkouts = db.table(\"workouts\", extracts=[Extract(\r\n columns=[\"source\", \"source_version\"],\r\n table=\"Sources\"\r\n)])\r\n```\r\nSince namedtuples cannot have default values this should probably be a class instead. Actually it looks like there is a trick for defaults here: https://stackoverflow.com/a/18348004", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 472115381, "label": "extracts= should support multiple-column extracts"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/49#issuecomment-710346830", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/49", "id": 710346830, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMDM0NjgzMA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-16T18:08:52Z", "updated_at": "2020-10-16T18:09:21Z", "author_association": "OWNER", "body": "The new `.extract()` method can handle multiple columns:\r\n\r\nhttps://github.com/simonw/sqlite-utils/blob/2c541fac352632e23e40b0d21e3f233f7a744a57/tests/test_extract.py#L70-L87", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 472115381, "label": "extracts= should support multiple-column extracts"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/49#issuecomment-710359724", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/49", "id": 710359724, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMDM1OTcyNA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-16T18:15:31Z", "updated_at": "2020-10-16T18:15:31Z", "author_association": "OWNER", "body": "Using a tuple would work:\r\n```python\r\nfresh_db.table(\"tree\", extracts=[(\"common_name\", \"latin_name\")])\r\n```\r\nOr to define a custom name:\r\n```python\r\nfresh_db.table(\"tree\", extracts={(\"common_name\", \"latin_name\"): \"names\"})\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 472115381, "label": "extracts= should support multiple-column extracts"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/49#issuecomment-710363789", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/49", "id": 710363789, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMDM2Mzc4OQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-16T18:18:05Z", "updated_at": "2020-10-16T18:18:05Z", "author_association": "OWNER", "body": "I wonder if there's value in extending the `extracts=` option at all given the existence of `table.extract()`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 472115381, "label": "extracts= should support multiple-column extracts"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/49#issuecomment-710364942", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/49", "id": 710364942, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMDM2NDk0Mg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-16T18:18:48Z", "updated_at": "2020-10-16T18:18:48Z", "author_association": "OWNER", "body": "I think there is. It's a nice existing feature, and I don't think adding tuple support to it would be a huge lift.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 472115381, "label": "extracts= should support multiple-column extracts"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/49#issuecomment-710390915", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/49", "id": 710390915, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMDM5MDkxNQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-16T18:34:26Z", "updated_at": "2020-10-16T18:34:50Z", "author_association": "OWNER", "body": "Here's the most complex example of `.extracts()`:\r\n```python\r\ndb[\"Trees\"].extract(\r\n [\"CommonName\", \"LatinName\"],\r\n table=\"Species\",\r\n fk_column=\"species_id\",\r\n rename={\"CommonName\": \"name\", \"LatinName\": \"latin\"}\r\n)\r\n```\r\nResulting in:\r\n```sql\r\nCREATE TABLE [Species] (\r\n [id] INTEGER PRIMARY KEY,\r\n [name] TEXT,\r\n [latin] TEXT\r\n)\r\n```\r\nFrom https://sqlite-utils.readthedocs.io/en/stable/python-api.html#extracting-columns-into-a-separate-table", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 472115381, "label": "extracts= should support multiple-column extracts"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/49#issuecomment-710393550", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/49", "id": 710393550, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMDM5MzU1MA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-16T18:35:57Z", "updated_at": "2020-10-16T18:36:39Z", "author_association": "OWNER", "body": "If I want to support that most complicated example, I think the option to pass a `Extracts()` object to `extracts=` is the best way to do it:\r\n```python\r\nfresh_db.table(\"tree\", extracts=[Extract(\r\n columns=(\"CommonName\", \"LatinName\"),\r\n table=\"Species\",\r\n fk_column=\"species_id\",\r\n rename={\"CommonName\": \"name\", \"LatinName\": \"latin\"}\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": 472115381, "label": "extracts= should support multiple-column extracts"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/49#issuecomment-710395444", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/49", "id": 710395444, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMDM5NTQ0NA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-16T18:37:10Z", "updated_at": "2020-10-16T18:37:10Z", "author_association": "OWNER", "body": "But this begins to feel too complicated, given that `table.extract()` can already be used to achieve the same thing.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 472115381, "label": "extracts= should support multiple-column extracts"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/49#issuecomment-710397574", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/49", "id": 710397574, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMDM5NzU3NA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-16T18:38:21Z", "updated_at": "2020-10-16T18:38:21Z", "author_association": "OWNER", "body": "I'm not going to implement this. I'll leave `extract=...` as it is right now, suitable for quick simple single-column operations on input, but if users want to do something more complicated involving multiple columns they should use the `table.extract()` method after the initial insert instead.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 472115381, "label": "extracts= should support multiple-column extracts"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/49#issuecomment-710461468", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/49", "id": 710461468, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMDQ2MTQ2OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-16T19:18:19Z", "updated_at": "2020-10-16T19:18:19Z", "author_association": "OWNER", "body": "Reconsidering: #89 was a feature request that relates to this, so maybe this is worth implementing after all.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 472115381, "label": "extracts= should support multiple-column extracts"}, "performed_via_github_app": null}