home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

11 rows where issue = 1077431957 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 11

issue 1

  • `sqlite-utils insert --convert` option · 11 ✖

author_association 1

  • OWNER 11
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
1006318443 https://github.com/simonw/sqlite-utils/issues/356#issuecomment-1006318443 https://api.github.com/repos/simonw/sqlite-utils/issues/356 IC_kwDOCGYnMM47-zNr simonw 9599 2022-01-06T06:30:13Z 2022-01-06T06:30:13Z OWNER

Documentation:

  • https://sqlite-utils.datasette.io/en/latest/cli.html#inserting-unstructured-data-with-lines-and-text
  • https://sqlite-utils.datasette.io/en/latest/cli.html#applying-conversions-while-inserting-data
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`sqlite-utils insert --convert` option 1077431957  
1006318007 https://github.com/simonw/sqlite-utils/issues/356#issuecomment-1006318007 https://api.github.com/repos/simonw/sqlite-utils/issues/356 IC_kwDOCGYnMM47-zG3 simonw 9599 2022-01-06T06:28:53Z 2022-01-06T06:28:53Z OWNER

Implemented in #361.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`sqlite-utils insert --convert` option 1077431957  
997496626 https://github.com/simonw/sqlite-utils/issues/356#issuecomment-997496626 https://api.github.com/repos/simonw/sqlite-utils/issues/356 IC_kwDOCGYnMM47dJcy simonw 9599 2021-12-20T00:38:15Z 2022-01-06T01:29:03Z OWNER

The implementation of this gets a tiny bit complicated.

Ignoring --convert, the --lines option can internally produce {"line": ...} records and the --all option can produce {"all": ...} records.

But... when --convert is used, what should the code run against?

It could run against those already-converted records but that's a little bit strange, since you'd have to do this:

sqlite-utils insert blah.db blah myfile.txt --all --convert '{"item": s for s in value["all"].split("-")}'

Having to use value["all"] there is unintuitive. It would be nicer to have a all variable to work against.

But then for --lines should the local variable be called line? And how best to summarize these different names for local variables in the inline help for the feature?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`sqlite-utils insert --convert` option 1077431957  
997507074 https://github.com/simonw/sqlite-utils/issues/356#issuecomment-997507074 https://api.github.com/repos/simonw/sqlite-utils/issues/356 IC_kwDOCGYnMM47dMAC simonw 9599 2021-12-20T01:10:06Z 2021-12-20T01:16:11Z OWNER

Work-in-progress improved help: ``` Usage: sqlite-utils insert [OPTIONS] PATH TABLE FILE

Insert records from FILE into a table, creating the table if it does not already exist.

By default the input is expected to be a JSON array of objects. Or:

  • Use --nl for newline-delimited JSON objects
  • Use --csv or --tsv for comma-separated or tab-separated input
  • Use --lines to write each incoming line to a column called "line"
  • Use --all to write the entire input to a column called "all"

You can also use --convert to pass a fragment of Python code that will be used to convert each input.

Your Python code will be passed a "row" variable representing the imported row, and can return a modified row.

If you are using --lines your code will be passed a "line" variable, and for --all an "all" variable.

Options: --pk TEXT Columns to use as the primary key, e.g. id --flatten Flatten nested JSON objects, so {"a": {"b": 1}} becomes {"a_b": 1} --nl Expect newline-delimited JSON -c, --csv Expect CSV input --tsv Expect TSV input --lines Treat each line as a single value called 'line' --all Treat input as a single value called 'all' --convert TEXT Python code to convert each item --import TEXT Python modules to import --delimiter TEXT Delimiter to use for CSV files --quotechar TEXT Quote character to use for CSV/TSV --sniff Detect delimiter and quote character --no-headers CSV file has no header row --batch-size INTEGER Commit every X records --alter Alter existing table to add any missing columns --not-null TEXT Columns that should be created as NOT NULL --default <TEXT TEXT>... Default value that should be set for a column --encoding TEXT Character encoding for input, defaults to utf-8 -d, --detect-types Detect types for columns in CSV/TSV data --load-extension TEXT SQLite extensions to load --silent Do not show progress bar --ignore Ignore records if pk already exists --replace Replace records if pk already exists --truncate Truncate table before inserting records, if table already exists -h, --help Show this message and exit. ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`sqlite-utils insert --convert` option 1077431957  
997508728 https://github.com/simonw/sqlite-utils/issues/356#issuecomment-997508728 https://api.github.com/repos/simonw/sqlite-utils/issues/356 IC_kwDOCGYnMM47dMZ4 simonw 9599 2021-12-20T01:14:43Z 2021-12-20T01:14:43Z OWNER

(This makes me want --extract from #352 even more.)

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`sqlite-utils insert --convert` option 1077431957  
997497262 https://github.com/simonw/sqlite-utils/issues/356#issuecomment-997497262 https://api.github.com/repos/simonw/sqlite-utils/issues/356 IC_kwDOCGYnMM47dJmu simonw 9599 2021-12-20T00:40:15Z 2021-12-20T00:40:15Z OWNER

--flatten could do with a better description too.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`sqlite-utils insert --convert` option 1077431957  
997496931 https://github.com/simonw/sqlite-utils/issues/356#issuecomment-997496931 https://api.github.com/repos/simonw/sqlite-utils/issues/356 IC_kwDOCGYnMM47dJhj simonw 9599 2021-12-20T00:39:14Z 2021-12-20T00:39:52Z OWNER

``` % sqlite-utils insert --help Usage: sqlite-utils insert [OPTIONS] PATH TABLE JSON_FILE

Insert records from JSON file into a table, creating the table if it does not already exist.

Input should be a JSON array of objects, unless --nl or --csv is used.

Options: --pk TEXT Columns to use as the primary key, e.g. id --nl Expect newline-delimited JSON --flatten Flatten nested JSON objects -c, --csv Expect CSV --tsv Expect TSV --convert TEXT Python code to convert each item --import TEXT Python modules to import --delimiter TEXT Delimiter to use for CSV files --quotechar TEXT Quote character to use for CSV/TSV --sniff Detect delimiter and quote character --no-headers CSV file has no header row --batch-size INTEGER Commit every X records --alter Alter existing table to add any missing columns --not-null TEXT Columns that should be created as NOT NULL --default <TEXT TEXT>... Default value that should be set for a column --encoding TEXT Character encoding for input, defaults to utf-8 -d, --detect-types Detect types for columns in CSV/TSV data --load-extension TEXT SQLite extensions to load --silent Do not show progress bar --ignore Ignore records if pk already exists --replace Replace records if pk already exists --truncate Truncate table before inserting records, if table already exists -h, --help Show this message and exit. ``` I can add a bunch of extra help at the top there to explain all of this stuff. That "Input should be a JSON array of objects" bit could be expanded to several paragraphs.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`sqlite-utils insert --convert` option 1077431957  
997492872 https://github.com/simonw/sqlite-utils/issues/356#issuecomment-997492872 https://api.github.com/repos/simonw/sqlite-utils/issues/356 IC_kwDOCGYnMM47dIiI simonw 9599 2021-12-20T00:23:31Z 2021-12-20T00:23:31Z OWNER

I think this should work on JSON, or CSV, or individual lines, or the entire content at once.

So I'll require --lines --convert ... to import individual lines, or --all --convert to run the conversion against the entire input at once.

What would --lines or --all do without --convert? Maybe insert records as {"line": "line of text"} or {"all": "whole input}.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`sqlite-utils insert --convert` option 1077431957  
997486156 https://github.com/simonw/sqlite-utils/issues/356#issuecomment-997486156 https://api.github.com/repos/simonw/sqlite-utils/issues/356 IC_kwDOCGYnMM47dG5M simonw 9599 2021-12-19T23:51:02Z 2021-12-19T23:51:02Z OWNER

This is going to need a --import multi option too.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`sqlite-utils insert --convert` option 1077431957  
997485361 https://github.com/simonw/sqlite-utils/issues/356#issuecomment-997485361 https://api.github.com/repos/simonw/sqlite-utils/issues/356 IC_kwDOCGYnMM47dGsx simonw 9599 2021-12-19T23:45:30Z 2021-12-19T23:45:30Z OWNER

Really interesting example input for this: https://blog.timac.org/2021/1219-state-of-swift-and-swiftui-ios15/iOS13.txt - see https://blog.timac.org/2021/1219-state-of-swift-and-swiftui-ios15/

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`sqlite-utils insert --convert` option 1077431957  
991517209 https://github.com/simonw/sqlite-utils/issues/356#issuecomment-991517209 https://api.github.com/repos/simonw/sqlite-utils/issues/356 IC_kwDOCGYnMM47GVoZ simonw 9599 2021-12-11T07:46:41Z 2021-12-11T07:46:41Z OWNER

By default this will accept single lines, but maybe there could be a --all option which instead grabs all of stdin into a single string against which the conversion function runs - like git-history file.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`sqlite-utils insert --convert` option 1077431957  

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 18.699ms · About: github-to-sqlite
  • Sort ascending
  • Sort descending
  • Facet by this
  • Hide this column
  • Show all columns
  • Show not-blank rows