home / github

Menu
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

8 rows where issue = 1077102934

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: user, author_association, reactions, created_at (date), updated_at (date)

id ▼ html_url issue_url node_id user created_at updated_at author_association body reactions issue performed_via_github_app
991376639 https://github.com/simonw/sqlite-utils/issues/353#issuecomment-991376639 https://api.github.com/repos/simonw/sqlite-utils/issues/353 IC_kwDOCGYnMM47FzT_ simonw 9599 2021-12-10T23:43:45Z 2021-12-10T23:43:45Z OWNER There's a very non-obvious workaround for this at the moment. You can save your code in e.g. a file called` transform.py` - my test one looks like this: ```python def upper(value): return value.upper() ``` Then you can run the following to import and use that function: `PYTHONPATH=. sqlite-utils convert fixtures.db roadside_attractions name 'transform.upper(value)' --import transform` That `PYTHONPATH=. bit is necessary because otherwise the script won't look in the current directory for that `transform.py` module. Now that I've written this down, it's obviously bad! I think your suggestion here is a good idea. {"total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} Allow passing a file of code to "sqlite-utils convert" 1077102934  
991377288 https://github.com/simonw/sqlite-utils/issues/353#issuecomment-991377288 https://api.github.com/repos/simonw/sqlite-utils/issues/353 IC_kwDOCGYnMM47FzeI simonw 9599 2021-12-10T23:45:53Z 2021-12-10T23:45:53Z OWNER One challenge here: the current signature looks like this: ``` % sqlite-utils convert --help Usage: sqlite-utils convert [OPTIONS] DB_PATH TABLE COLUMNS... CODE ``` `CODE` is a positional argument which comes last - and since `COLUMNS` can be one or more items, making `CODE` optional isn't easy. {"total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} Allow passing a file of code to "sqlite-utils convert" 1077102934  
991378346 https://github.com/simonw/sqlite-utils/issues/353#issuecomment-991378346 https://api.github.com/repos/simonw/sqlite-utils/issues/353 IC_kwDOCGYnMM47Fzuq simonw 9599 2021-12-10T23:48:28Z 2021-12-10T23:48:28Z OWNER One option: allow `CODE` to be a special value of `-` which means "read from standard input". It's a tiny bit of a hack but I think it would work here. If you wanted to replace a column entirely with hyphens you would still be able to do this: sqlite-utils convert my.db mytable col1 '"-"' {"total_count": 1, "+1": 1, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} Allow passing a file of code to "sqlite-utils convert" 1077102934  
991381281 https://github.com/simonw/sqlite-utils/issues/353#issuecomment-991381281 https://api.github.com/repos/simonw/sqlite-utils/issues/353 IC_kwDOCGYnMM47F0ch simonw 9599 2021-12-10T23:57:26Z 2021-12-10T23:57:26Z OWNER My first attempt at building this looked a little bit strange, because you would end up having a file like this `convert.py`: ``` value = value.upper() return value ``` Which gets used like this: cat convert.py | sqlite-utils convert my.db mytable col1 - But... that `convert.py` code isn't actually valid Python - it's a weird thing where you have a partial snippet of Python code that gets wrapped in a function automatically. It would be better if you could write `convert.py` as a valid Python file with a function in it, something like this: ```python def convert(value): value = value.upper() return value ``` {"total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} Allow passing a file of code to "sqlite-utils convert" 1077102934  
991381679 https://github.com/simonw/sqlite-utils/issues/353#issuecomment-991381679 https://api.github.com/repos/simonw/sqlite-utils/issues/353 IC_kwDOCGYnMM47F0iv simonw 9599 2021-12-10T23:58:43Z 2021-12-10T23:59:35Z OWNER I think the fix for this is to change the rules about what code is accepted in both the `-` mode and the literal code string mode: you can pass in a Python expression, OR a fragment that gets turned into a function, OR code that implements its own `def convert(value)` function. So this would work too: ```sh sqlite-utils convert my.db mytable col1 ' def convert(value): return value.upper() ' ``` {"total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} Allow passing a file of code to "sqlite-utils convert" 1077102934  
991399782 https://github.com/simonw/sqlite-utils/issues/353#issuecomment-991399782 https://api.github.com/repos/simonw/sqlite-utils/issues/353 IC_kwDOCGYnMM47F49m simonw 9599 2021-12-11T01:09:37Z 2021-12-11T01:09:37Z OWNER OK, this is implemented. Updated documentation is here: https://sqlite-utils.datasette.io/en/latest/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} Allow passing a file of code to "sqlite-utils convert" 1077102934  
991400016 https://github.com/simonw/sqlite-utils/issues/353#issuecomment-991400016 https://api.github.com/repos/simonw/sqlite-utils/issues/353 IC_kwDOCGYnMM47F5BQ simonw 9599 2021-12-11T01:10:52Z 2021-12-11T01:11:02Z OWNER This won't be in a release for a little while, but you can install it to try it out using: pip install https://github.com/simonw/sqlite-utils/archive/ee13f98c2c.zip {"total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} Allow passing a file of code to "sqlite-utils convert" 1077102934  
991405755 https://github.com/simonw/sqlite-utils/issues/353#issuecomment-991405755 https://api.github.com/repos/simonw/sqlite-utils/issues/353 IC_kwDOCGYnMM47F6a7 fgregg 536941 2021-12-11T01:38:29Z 2021-12-11T01:38:29Z CONTRIBUTOR wow! that's awesome! thanks so much, @simonw! {"total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} Allow passing a file of code to "sqlite-utils convert" 1077102934  

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 25.217ms · About: simonw/datasette-graphql