{"html_url": "https://github.com/simonw/sqlite-utils/issues/251#issuecomment-891380382", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/251", "id": 891380382, "node_id": "IC_kwDOCGYnMM41IWKe", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-08-02T22:39:46Z", "updated_at": "2021-08-02T22:39:46Z", "author_association": "OWNER", "body": "Documentation: https://sqlite-utils.datasette.io/en/stable/cli.html#converting-data-in-columns", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 841377702, "label": "\"sqlite-utils convert\" command to replace the separate \"sqlite-transform\" tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890553783", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/251", "id": 890553783, "node_id": "IC_kwDOCGYnMM41FMW3", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-08-01T16:59:09Z", "updated_at": "2021-08-01T16:59:09Z", "author_association": "OWNER", "body": "I'm going with `recipes.jsonsplit()` rather than `recipe.jsonsplit()` because the Python module containing the recipes will be called `recipes`. I'll set up a `r.jsonsplit()` shortcut too as a convenience.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 841377702, "label": "\"sqlite-utils convert\" command to replace the separate \"sqlite-transform\" tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890552827", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/251", "id": 890552827, "node_id": "IC_kwDOCGYnMM41FMH7", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-08-01T16:52:00Z", "updated_at": "2021-08-01T16:52:00Z", "author_association": "OWNER", "body": "I'll finish the work on this in a PR.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 841377702, "label": "\"sqlite-utils convert\" command to replace the separate \"sqlite-transform\" tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890448623", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/251", "id": 890448623, "node_id": "IC_kwDOCGYnMM41Eyrv", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-08-01T04:33:30Z", "updated_at": "2021-08-01T04:33:30Z", "author_association": "OWNER", "body": "I've started an implementation in the `convert` branch - no documentation yet, and I've not implemented the recipes.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 841377702, "label": "\"sqlite-utils convert\" command to replace the separate \"sqlite-transform\" tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890448119", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/251", "id": 890448119, "node_id": "IC_kwDOCGYnMM41Eyj3", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-08-01T04:28:05Z", "updated_at": "2021-08-01T04:30:28Z", "author_association": "OWNER", "body": "In which case I think `--code` should be a positional argument instead:\r\n```\r\nsqlite-utils convert mydb.db mytable col 'recipe.parsedatetime(value, dayfirst=True)'\r\nsqlite-utils convert mydb.db mytable col 'recipe.jsonsplit(value, delimiter=\":\")'\r\nsqlite-utils convert mydb.db mytable col 'recipe.jsonsplit(value, delimiter=\":\")'\r\nsqlite-utils convert mydb.db mytable col '{\"lower\": value.lower(), \"upper\": value.upper()}' --multi\r\n```\r\nOne problem with this: we already accept one or more columns. I think that's OK though since the code is now a required argument, so it means we have to treat everything between the table and the final code argument as a column.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 841377702, "label": "\"sqlite-utils convert\" command to replace the separate \"sqlite-transform\" tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890447102", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/251", "id": 890447102, "node_id": "IC_kwDOCGYnMM41EyT-", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-08-01T04:20:18Z", "updated_at": "2021-08-01T04:29:26Z", "author_association": "OWNER", "body": "I could stick them in a `recipe` namespace so you do this:\r\n```\r\nsqlite-utils convert mydb.db mytable col --code 'recipe.parsedatetime(value, dayfirst=True)'\r\nsqlite-utils convert mydb.db mytable col --code 'recipe.jsonsplit(value, delimiter=\":\")'\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 841377702, "label": "\"sqlite-utils convert\" command to replace the separate \"sqlite-transform\" tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890448190", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/251", "id": 890448190, "node_id": "IC_kwDOCGYnMM41Eyk-", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-08-01T04:28:49Z", "updated_at": "2021-08-01T04:28:49Z", "author_association": "OWNER", "body": "Would make sense to accept code from standard input too:\r\n\r\n echo 'value.upper()' | sqlite-utils convert my.db mytable col -", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 841377702, "label": "\"sqlite-utils convert\" command to replace the separate \"sqlite-transform\" tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890446808", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/251", "id": 890446808, "node_id": "IC_kwDOCGYnMM41EyPY", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-08-01T04:18:18Z", "updated_at": "2021-08-01T04:28:18Z", "author_association": "OWNER", "body": "Or.... how about making the `parsedate()` and `parsedatetime()` and `jsonsplit()` functions available within the namespace that is configured for the `--code` block?\r\n\r\nThen you could do something like this:\r\n\r\n```\r\nsqlite-utils convert mydb.db mytable col --code 'parsedatetime(value, dayfirst=True)'\r\nsqlite-utils convert mydb.db mytable col --code 'jsonsplit(value, delimiter=\":\")'\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 841377702, "label": "\"sqlite-utils convert\" command to replace the separate \"sqlite-transform\" tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890446943", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/251", "id": 890446943, "node_id": "IC_kwDOCGYnMM41EyRf", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-08-01T04:19:09Z", "updated_at": "2021-08-01T04:19:09Z", "author_association": "OWNER", "body": "That's a pretty neat fix, though it's a bit more challenging on the documentation front - maybe the help text for `sqlite-utils convert --help` gets a fair bit longer?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 841377702, "label": "\"sqlite-utils convert\" command to replace the separate \"sqlite-transform\" tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890446506", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/251", "id": 890446506, "node_id": "IC_kwDOCGYnMM41EyKq", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-08-01T04:16:36Z", "updated_at": "2021-08-01T04:16:36Z", "author_association": "OWNER", "body": "Back to the design board then. One way to handle this would be the long-form:\r\n\r\n```\r\nsqlite-utils convert jsonsplit mydb.db mytable mycolumn\r\nsqlite-utils convert parsedatetime mydb.db mytable mycolumn\r\nsqlite-utils convert parsedate mydb.db mytable mycolumn\r\nsqlite-utils convert lambda mydb.db mytable mycolumn --code='str(value).upper()'\r\n```\r\nI like the idea that `lambda` is the default action, but in this form it's required that the second argument (the word after `convert`) be the name of the recipe that is being applied to avoid any potential confusion with the database filename.\r\n\r\nAn ugly solution would be to make all four of those options available on `sqlite-utils convert` - and return an error if you try and use one of those without specifying the accompanying recipe. That's a bit gross though.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 841377702, "label": "\"sqlite-utils convert\" command to replace the separate \"sqlite-transform\" tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890446166", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/251", "id": 890446166, "node_id": "IC_kwDOCGYnMM41EyFW", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-08-01T04:14:26Z", "updated_at": "2021-08-01T04:14:26Z", "author_association": "OWNER", "body": "Problem with the `-r/--recipe` idea: the `parsedate` and `parsedatetime` and `jsonsplit` recipes in the current `sqlite-transform` tool all take additional options.\r\n\r\nFor `sqlite-transform parsedate` and `parsedatetime`:\r\n\r\n```python\r\n@click.option(\r\n \"--dayfirst\",\r\n is_flag=True,\r\n help=\"Assume day comes first in ambiguous dates, e.g. 03/04/05\",\r\n)\r\n@click.option(\r\n \"--yearfirst\",\r\n is_flag=True,\r\n help=\"Assume year comes first in ambiguous dates, e.g. 03/04/05\",\r\n)\r\n```\r\nFor `jsonsplit`:\r\n```python\r\n@click.option(\"--delimiter\", default=\",\", help=\"Delimiter to split on\")\r\n@click.option(\r\n \"--type\",\r\n type=click.Choice((\"int\", \"float\")),\r\n help=\"Type to use for values - int or float (defaults to string)\",\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": 841377702, "label": "\"sqlite-utils convert\" command to replace the separate \"sqlite-transform\" tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890443079", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/251", "id": 890443079, "node_id": "IC_kwDOCGYnMM41ExVH", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-08-01T03:46:43Z", "updated_at": "2021-08-01T03:46:43Z", "author_association": "OWNER", "body": "Note that there's already a concept of `conversions` which might be confused with `convert`? https://sqlite-utils.datasette.io/en/stable/python-api.html#converting-column-values-using-sql-functions\r\n\r\n```python\r\ndb[\"example\"].insert({\r\n \"name\": \"The Bigfoot Discovery Museum\"\r\n}, conversions={\"name\": \"upper(?)\"})\r\n```\r\nI think that's OK though - that's a Python library feature, `sqlite-utils convert` is a CLI thing.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 841377702, "label": "\"sqlite-utils convert\" command to replace the separate \"sqlite-transform\" tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/251#issuecomment-886122696", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/251", "id": 886122696, "node_id": "IC_kwDOCGYnMM400SjI", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-07-24T23:21:32Z", "updated_at": "2021-07-24T23:21:32Z", "author_association": "OWNER", "body": "> ```\r\n> sqlite-utils convert jsonsplit mydb.db mytable mycolumn\r\n> sqlite-utils convert parsedatetime mydb.db mytable mycolumn\r\n> sqlite-utils convert parsedate mydb.db mytable mycolumn\r\n> sqlite-utils convert lambda mydb.db mytable mycolumn --code='str(value).upper()'\r\n> ```\r\n\r\nThis is a bit verbose - and having added `--multi` and `--output` the `lambda` command keeps getting more and more flexible compared to the others.\r\n\r\nNew idea: ditch the sub-sub-commands and move the `jsonsplit` and `parsedate` recipes to be options of `convert` - maybe like this:\r\n\r\n sqlite-utils convert my.db mytable col1 --jsonsplit\r\n\r\nor:\r\n\r\n sqlite-utils convert my.db mytable col1 --recipe jsonsplit\r\n\r\nor `-r jsonsplit` for short.\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": 841377702, "label": "\"sqlite-utils convert\" command to replace the separate \"sqlite-transform\" tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/251#issuecomment-807647791", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/251", "id": 807647791, "node_id": "MDEyOklzc3VlQ29tbWVudDgwNzY0Nzc5MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-03-25T22:42:48Z", "updated_at": "2021-03-25T22:44:31Z", "author_association": "OWNER", "body": "Idea: enhance `lambda` to allow it to return a dictionary of values, which will then be used to populate new columns. Use a `--multicolumn` option to indicate this:\r\n\r\n sqlite-utils convert lambda mydb.db mytable mycolumn \\\r\n --code '{\"first_name\": value.split()[0], \"last_name\": value.split()[1]}' \\\r\n --multicolumn --drop\r\n\r\nThe `--drop` means \"drop the `mycolumn` column after making this change\".\r\n\r\nMaybe `--multi` is a better name than `--multicolumn` here, since either way it's going to need additional explanation somewhere.\r\n\r\nWould this overlap with #239 at all?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 841377702, "label": "\"sqlite-utils convert\" command to replace the separate \"sqlite-transform\" tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/251#issuecomment-807642041", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/251", "id": 807642041, "node_id": "MDEyOklzc3VlQ29tbWVudDgwNzY0MjA0MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-03-25T22:39:22Z", "updated_at": "2021-03-25T22:39:22Z", "author_association": "OWNER", "body": "Here's the full current implementation of that tool: https://github.com/simonw/sqlite-transform/blob/0.5/sqlite_transform/cli.py\r\n\r\nMy current plan is to make this functionality available as the following:\r\n\r\n sqlite-utils convert jsonsplit mydb.db mytable mycolumn\r\n sqlite-utils convert parsedatetime mydb.db mytable mycolumn\r\n sqlite-utils convert parsedate mydb.db mytable mycolumn\r\n sqlite-utils convert lambda mydb.db mytable mycolumn --code='str(value).upper()'\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": 841377702, "label": "\"sqlite-utils convert\" command to replace the separate \"sqlite-transform\" tool"}, "performed_via_github_app": null}