{"html_url": "https://github.com/simonw/datasette/issues/1615#issuecomment-1023997327", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1615", "id": 1023997327, "node_id": "IC_kwDOBm6k_c49CPWP", "user": {"value": 369053, "label": "aidansteele"}, "created_at": "2022-01-28T08:37:36Z", "updated_at": "2022-01-28T08:37:36Z", "author_association": "NONE", "body": "Oops, it feels like this should perhaps be migrated to GitHub Discussions - sorry! I don't think I have the ability to do that \ud83d\ude05", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1117132741, "label": "Potential simplified publishing mechanism"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/352#issuecomment-1024726879", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/352", "id": 1024726879, "node_id": "IC_kwDOCGYnMM49FBdf", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-01-28T22:59:44Z", "updated_at": "2022-01-28T22:59:44Z", "author_association": "OWNER", "body": "Rough prototype, seems to work:;\r\n```diff\r\ndiff --git a/sqlite_utils/cli.py b/sqlite_utils/cli.py\r\nindex 771d432..431b93e 100644\r\n--- a/sqlite_utils/cli.py\r\n+++ b/sqlite_utils/cli.py\r\n@@ -867,6 +867,12 @@ def insert_upsert_options(*, require_pk=False):\r\n ),\r\n load_extension_option,\r\n click.option(\"--silent\", is_flag=True, help=\"Do not show progress bar\"),\r\n+ click.option(\r\n+ \"--extract\",\r\n+ \"extracts\",\r\n+ multiple=True,\r\n+ help=\"Columns to extract to another table\",\r\n+ ),\r\n )\r\n ):\r\n fn = decorator(fn)\r\n@@ -906,6 +912,7 @@ def insert_upsert_implementation(\r\n load_extension=None,\r\n silent=False,\r\n bulk_sql=None,\r\n+ extracts=None,\r\n ):\r\n db = sqlite_utils.Database(path)\r\n _load_extensions(db, load_extension)\r\n@@ -1008,6 +1015,8 @@ def insert_upsert_implementation(\r\n extra_kwargs[\"defaults\"] = dict(default)\r\n if upsert:\r\n extra_kwargs[\"upsert\"] = upsert\r\n+ if extracts is not None:\r\n+ extra_kwargs[\"extracts\"] = extracts\r\n \r\n # Apply {\"$base64\": true, ...} decoding, if needed\r\n docs = (decode_base64_values(doc) for doc in docs)\r\n@@ -1117,6 +1126,7 @@ def insert(\r\n truncate,\r\n not_null,\r\n default,\r\n+ extracts,\r\n ):\r\n \"\"\"\r\n Insert records from FILE into a table, creating the table if it\r\n@@ -1174,6 +1184,7 @@ def insert(\r\n silent=silent,\r\n not_null=not_null,\r\n default=default,\r\n+ extracts=extracts,\r\n )\r\n except UnicodeDecodeError as ex:\r\n raise click.ClickException(UNICODE_ERROR.format(ex))\r\n@@ -1207,6 +1218,7 @@ def upsert(\r\n analyze,\r\n load_extension,\r\n silent,\r\n+ extracts,\r\n ):\r\n \"\"\"\r\n Upsert records based on their primary key. Works like 'insert' but if\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1072792507, "label": "`sqlite-utils insert --extract colname`"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/352#issuecomment-1024727476", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/352", "id": 1024727476, "node_id": "IC_kwDOCGYnMM49FBm0", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-01-28T23:01:06Z", "updated_at": "2022-01-28T23:01:06Z", "author_association": "OWNER", "body": "Manual test run with that prototype:\r\n```\r\n% echo '{\"foo\": \"bar\", \"id\": 1}' | sqlite-utils insert insert-extract.db rows - --pk id --extract foo\r\n% sqlite-utils dump insert-extract.db \r\nBEGIN TRANSACTION;\r\nCREATE TABLE [foo] (\r\n [id] INTEGER PRIMARY KEY,\r\n [value] TEXT\r\n);\r\nINSERT INTO \"foo\" VALUES(1,'bar');\r\nCREATE TABLE [rows] (\r\n [foo] INTEGER REFERENCES [foo]([id]),\r\n [id] INTEGER PRIMARY KEY\r\n);\r\nINSERT INTO \"rows\" VALUES(1,1);\r\nCREATE UNIQUE INDEX [idx_foo_value]\r\n ON [foo] ([value]);\r\nCOMMIT;\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": 1072792507, "label": "`sqlite-utils insert --extract colname`"}, "performed_via_github_app": null}