home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

15 rows where issue = 841377702 sorted by updated_at descending

✖
✖

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: created_at (date), updated_at (date)

user 1

  • simonw 15

issue 1

  • "sqlite-utils convert" command to replace the separate "sqlite-transform" tool · 15 ✖

author_association 1

  • OWNER 15
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
891380382 https://github.com/simonw/sqlite-utils/issues/251#issuecomment-891380382 https://api.github.com/repos/simonw/sqlite-utils/issues/251 IC_kwDOCGYnMM41IWKe simonw 9599 2021-08-02T22:39:46Z 2021-08-02T22:39:46Z OWNER

Documentation: https://sqlite-utils.datasette.io/en/stable/cli.html#converting-data-in-columns

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
"sqlite-utils convert" command to replace the separate "sqlite-transform" tool 841377702  
890553783 https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890553783 https://api.github.com/repos/simonw/sqlite-utils/issues/251 IC_kwDOCGYnMM41FMW3 simonw 9599 2021-08-01T16:59:09Z 2021-08-01T16:59:09Z OWNER

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.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
"sqlite-utils convert" command to replace the separate "sqlite-transform" tool 841377702  
890552827 https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890552827 https://api.github.com/repos/simonw/sqlite-utils/issues/251 IC_kwDOCGYnMM41FMH7 simonw 9599 2021-08-01T16:52:00Z 2021-08-01T16:52:00Z OWNER

I'll finish the work on this in a PR.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
"sqlite-utils convert" command to replace the separate "sqlite-transform" tool 841377702  
890448623 https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890448623 https://api.github.com/repos/simonw/sqlite-utils/issues/251 IC_kwDOCGYnMM41Eyrv simonw 9599 2021-08-01T04:33:30Z 2021-08-01T04:33:30Z OWNER

I've started an implementation in the convert branch - no documentation yet, and I've not implemented the recipes.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
"sqlite-utils convert" command to replace the separate "sqlite-transform" tool 841377702  
890448119 https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890448119 https://api.github.com/repos/simonw/sqlite-utils/issues/251 IC_kwDOCGYnMM41Eyj3 simonw 9599 2021-08-01T04:28:05Z 2021-08-01T04:30:28Z OWNER

In which case I think --code should be a positional argument instead: sqlite-utils convert mydb.db mytable col 'recipe.parsedatetime(value, dayfirst=True)' sqlite-utils convert mydb.db mytable col 'recipe.jsonsplit(value, delimiter=":")' sqlite-utils convert mydb.db mytable col 'recipe.jsonsplit(value, delimiter=":")' sqlite-utils convert mydb.db mytable col '{"lower": value.lower(), "upper": value.upper()}' --multi One 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.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
"sqlite-utils convert" command to replace the separate "sqlite-transform" tool 841377702  
890447102 https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890447102 https://api.github.com/repos/simonw/sqlite-utils/issues/251 IC_kwDOCGYnMM41EyT- simonw 9599 2021-08-01T04:20:18Z 2021-08-01T04:29:26Z OWNER

I could stick them in a recipe namespace so you do this: sqlite-utils convert mydb.db mytable col --code 'recipe.parsedatetime(value, dayfirst=True)' sqlite-utils convert mydb.db mytable col --code 'recipe.jsonsplit(value, delimiter=":")'

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
"sqlite-utils convert" command to replace the separate "sqlite-transform" tool 841377702  
890448190 https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890448190 https://api.github.com/repos/simonw/sqlite-utils/issues/251 IC_kwDOCGYnMM41Eyk- simonw 9599 2021-08-01T04:28:49Z 2021-08-01T04:28:49Z OWNER

Would make sense to accept code from standard input too:

echo 'value.upper()' | sqlite-utils convert my.db mytable col -
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
"sqlite-utils convert" command to replace the separate "sqlite-transform" tool 841377702  
890446808 https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890446808 https://api.github.com/repos/simonw/sqlite-utils/issues/251 IC_kwDOCGYnMM41EyPY simonw 9599 2021-08-01T04:18:18Z 2021-08-01T04:28:18Z OWNER

Or.... how about making the parsedate() and parsedatetime() and jsonsplit() functions available within the namespace that is configured for the --code block?

Then you could do something like this:

sqlite-utils convert mydb.db mytable col --code 'parsedatetime(value, dayfirst=True)' sqlite-utils convert mydb.db mytable col --code 'jsonsplit(value, delimiter=":")'

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
"sqlite-utils convert" command to replace the separate "sqlite-transform" tool 841377702  
890446943 https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890446943 https://api.github.com/repos/simonw/sqlite-utils/issues/251 IC_kwDOCGYnMM41EyRf simonw 9599 2021-08-01T04:19:09Z 2021-08-01T04:19:09Z OWNER

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?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
"sqlite-utils convert" command to replace the separate "sqlite-transform" tool 841377702  
890446506 https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890446506 https://api.github.com/repos/simonw/sqlite-utils/issues/251 IC_kwDOCGYnMM41EyKq simonw 9599 2021-08-01T04:16:36Z 2021-08-01T04:16:36Z OWNER

Back to the design board then. One way to handle this would be the long-form:

sqlite-utils convert jsonsplit mydb.db mytable mycolumn sqlite-utils convert parsedatetime mydb.db mytable mycolumn sqlite-utils convert parsedate mydb.db mytable mycolumn sqlite-utils convert lambda mydb.db mytable mycolumn --code='str(value).upper()' I 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.

An 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.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
"sqlite-utils convert" command to replace the separate "sqlite-transform" tool 841377702  
890446166 https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890446166 https://api.github.com/repos/simonw/sqlite-utils/issues/251 IC_kwDOCGYnMM41EyFW simonw 9599 2021-08-01T04:14:26Z 2021-08-01T04:14:26Z OWNER

Problem with the -r/--recipe idea: the parsedate and parsedatetime and jsonsplit recipes in the current sqlite-transform tool all take additional options.

For sqlite-transform parsedate and parsedatetime:

python @click.option( "--dayfirst", is_flag=True, help="Assume day comes first in ambiguous dates, e.g. 03/04/05", ) @click.option( "--yearfirst", is_flag=True, help="Assume year comes first in ambiguous dates, e.g. 03/04/05", ) For jsonsplit: python @click.option("--delimiter", default=",", help="Delimiter to split on") @click.option( "--type", type=click.Choice(("int", "float")), help="Type to use for values - int or float (defaults to string)", )

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
"sqlite-utils convert" command to replace the separate "sqlite-transform" tool 841377702  
890443079 https://github.com/simonw/sqlite-utils/issues/251#issuecomment-890443079 https://api.github.com/repos/simonw/sqlite-utils/issues/251 IC_kwDOCGYnMM41ExVH simonw 9599 2021-08-01T03:46:43Z 2021-08-01T03:46:43Z OWNER

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

python db["example"].insert({ "name": "The Bigfoot Discovery Museum" }, conversions={"name": "upper(?)"}) I think that's OK though - that's a Python library feature, sqlite-utils convert is a CLI thing.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
"sqlite-utils convert" command to replace the separate "sqlite-transform" tool 841377702  
886122696 https://github.com/simonw/sqlite-utils/issues/251#issuecomment-886122696 https://api.github.com/repos/simonw/sqlite-utils/issues/251 IC_kwDOCGYnMM400SjI simonw 9599 2021-07-24T23:21:32Z 2021-07-24T23:21:32Z OWNER

sqlite-utils convert jsonsplit mydb.db mytable mycolumn sqlite-utils convert parsedatetime mydb.db mytable mycolumn sqlite-utils convert parsedate mydb.db mytable mycolumn sqlite-utils convert lambda mydb.db mytable mycolumn --code='str(value).upper()'

This is a bit verbose - and having added --multi and --output the lambda command keeps getting more and more flexible compared to the others.

New idea: ditch the sub-sub-commands and move the jsonsplit and parsedate recipes to be options of convert - maybe like this:

sqlite-utils convert my.db mytable col1 --jsonsplit

or:

sqlite-utils convert my.db mytable col1 --recipe jsonsplit

or -r jsonsplit for short.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
"sqlite-utils convert" command to replace the separate "sqlite-transform" tool 841377702  
807647791 https://github.com/simonw/sqlite-utils/issues/251#issuecomment-807647791 https://api.github.com/repos/simonw/sqlite-utils/issues/251 MDEyOklzc3VlQ29tbWVudDgwNzY0Nzc5MQ== simonw 9599 2021-03-25T22:42:48Z 2021-03-25T22:44:31Z OWNER

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:

sqlite-utils convert lambda mydb.db mytable mycolumn \
  --code '{"first_name": value.split()[0], "last_name": value.split()[1]}' \
  --multicolumn --drop

The --drop means "drop the mycolumn column after making this change".

Maybe --multi is a better name than --multicolumn here, since either way it's going to need additional explanation somewhere.

Would this overlap with #239 at all?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
"sqlite-utils convert" command to replace the separate "sqlite-transform" tool 841377702  
807642041 https://github.com/simonw/sqlite-utils/issues/251#issuecomment-807642041 https://api.github.com/repos/simonw/sqlite-utils/issues/251 MDEyOklzc3VlQ29tbWVudDgwNzY0MjA0MQ== simonw 9599 2021-03-25T22:39:22Z 2021-03-25T22:39:22Z OWNER

Here's the full current implementation of that tool: https://github.com/simonw/sqlite-transform/blob/0.5/sqlite_transform/cli.py

My current plan is to make this functionality available as the following:

sqlite-utils convert jsonsplit mydb.db mytable mycolumn
sqlite-utils convert parsedatetime mydb.db mytable mycolumn
sqlite-utils convert parsedate mydb.db mytable mycolumn
sqlite-utils convert lambda mydb.db mytable mycolumn --code='str(value).upper()'
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
"sqlite-utils convert" command to replace the separate "sqlite-transform" tool 841377702  

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
, [performed_via_github_app] TEXT);
CREATE INDEX [idx_issue_comments_issue]
                ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
                ON [issue_comments] ([user]);
Powered by Datasette · Queries took 21.989ms · About: github-to-sqlite
  • Sort ascending
  • Sort descending
  • Facet by this
  • Hide this column
  • Show all columns
  • Show not-blank rows