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