home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

3 rows where issue = 470345929, "updated_at" is on date 2019-07-19 and user = 9599 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 · 3 ✖

issue 1

  • table.extract(...) method and "sqlite-utils extract" command · 3 ✖

author_association 1

  • OWNER 3
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
513246831 https://github.com/simonw/sqlite-utils/issues/42#issuecomment-513246831 https://api.github.com/repos/simonw/sqlite-utils/issues/42 MDEyOklzc3VlQ29tbWVudDUxMzI0NjgzMQ== simonw 9599 2019-07-19T14:20:15Z 2019-07-19T14:20:49Z OWNER

Since these operations could take a long time against large tables, it would be neat if there was a progress bar option for the CLI command.

The operations are full table scans so calculating progress shouldn't be too difficult.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.extract(...) method and "sqlite-utils extract" command 470345929  
513246124 https://github.com/simonw/sqlite-utils/issues/42#issuecomment-513246124 https://api.github.com/repos/simonw/sqlite-utils/issues/42 MDEyOklzc3VlQ29tbWVudDUxMzI0NjEyNA== simonw 9599 2019-07-19T14:18:35Z 2019-07-19T14:19:40Z OWNER

How about the Python version? That should be easier to design.

python db["dea_sales"].extract( columns=["company_name", "company_address"], to_table="companies" ) If we want to transform the extracted data (e.g. rename those columns) maybe support a transform= argument?

python db["dea_sales"].extract( columns=["company_name", "company_address"], to_table="companies", transform = lambda extracted: { "name": extracted["company_name"], "address": extracted["company_address"], } ) This would create a new "companies" table with three columns: id, name and address.

Would also be nice if there was a syntax for saying "... and use the value from this column as the primary key column in the newly created table".

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.extract(...) method and "sqlite-utils extract" command 470345929  
513244121 https://github.com/simonw/sqlite-utils/issues/42#issuecomment-513244121 https://api.github.com/repos/simonw/sqlite-utils/issues/42 MDEyOklzc3VlQ29tbWVudDUxMzI0NDEyMQ== simonw 9599 2019-07-19T14:13:33Z 2019-07-19T14:13:33Z OWNER

So what could the interface to this look like? Especially for the CLI?

One option:

sqlite-utils extract dea_sales company_name companies name

Tricky thing here is that it's quite a large number of positional arguments:

sqlite-utils extract dea_sales company_name companies name
                     Table     column       New table New column (maybe optional?)

It would be great if this could supported multiple columns - for if a spreadsheet has e.g. a “Company Name”, “Company Address” pair of fields that always match each other and areduplicated many times.

This could be handled by creating the new table with two columns that are indexed as a unique compound key. Then you can easily get-or-create on the pairs (or triples or whatever) from the original table.

Challenge here is what does the CLI syntax look like. Something like this?

$ sqlite-utils extract dea_sales -c company_name -c company_address \
  --to companies --to-col name --to-col address

Perhaps the columns in the new table are FORCED to be the same as the old ones, hence avoiding some options? Bit restrictive… maybe they default to the same but you can customize?

$ sqlite-utils extract dea_sales -c company_name -c company_address -t companies
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.extract(...) method and "sqlite-utils extract" command 470345929  

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 447.083ms · About: github-to-sqlite