home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

8 rows where issue = 1160034488 sorted by updated_at descending

✖
✖

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 2

  • simonw 7
  • eyeseast 1

author_association 2

  • OWNER 7
  • CONTRIBUTOR 1

issue 1

  • Support for generated columns · 8 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
1065597709 https://github.com/simonw/sqlite-utils/issues/411#issuecomment-1065597709 https://api.github.com/repos/simonw/sqlite-utils/issues/411 IC_kwDOCGYnMM4_g7sN simonw 9599 2022-03-11T22:32:43Z 2022-03-11T22:32:43Z OWNER

Trying to figure out what that extra field in table_info compared to table_xinfo is: ```

list(db.query("PRAGMA table_xinfo('t')")) [{'cid': 0, 'name': 'body', 'type': 'TEXT', 'notnull': 0, 'dflt_value': None, 'pk': 0, 'hidden': 0}, {'cid': 1, 'name': 'd', 'type': 'INT', 'notnull': 0, 'dflt_value': None, 'pk': 0, 'hidden': 2}] ` Presumablyhidden` 0 v.s 2 v.s. other values has meaning.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support for generated columns 1160034488  
1065596417 https://github.com/simonw/sqlite-utils/issues/411#issuecomment-1065596417 https://api.github.com/repos/simonw/sqlite-utils/issues/411 IC_kwDOCGYnMM4_g7YB simonw 9599 2022-03-11T22:30:15Z 2022-03-11T22:30:15Z OWNER

I tried it out in Jupyter and it works as advertised:

Introspection is a bit weird: there doesn't seem to be a way to introspect generated columns outside of parsing the stored SQL schema for the columns at the moment! And the .columns method doesn't return them at all:

https://github.com/simonw/sqlite-utils/blob/433813612ff9b4b501739fd7543bef0040dd51fe/sqlite_utils/db.py#L1207-L1213

Here's why:

```

db.execute("PRAGMA table_info('t')").fetchall() [(0, 'body', 'TEXT', 0, None, 0)] db.execute("PRAGMA table_xinfo('t')").fetchall() [(0, 'body', 'TEXT', 0, None, 0, 0), (1, 'd', 'INT', 0, None, 0, 2)] `` Sotable_xinfo()` is needed to get back columns including generated columns: https://www.sqlite.org/pragma.html#pragma_table_xinfo

PRAGMA schema.table_xinfo(table-name);

This pragma returns one row for each column in the named table, including hidden columns in virtual tables. The output is the same as for PRAGMA table_info except that hidden columns are shown rather than being omitted.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support for generated columns 1160034488  
1065402557 https://github.com/simonw/sqlite-utils/issues/411#issuecomment-1065402557 https://api.github.com/repos/simonw/sqlite-utils/issues/411 IC_kwDOCGYnMM4_gMC9 simonw 9599 2022-03-11T19:01:08Z 2022-03-11T21:42:25Z OWNER

Just spotted this in https://www.sqlite.org/gencol.html

The only functional difference is that one cannot add new STORED columns using the ALTER TABLE ADD COLUMN command. Only VIRTUAL columns can be added using ALTER TABLE.

So to add stored columns to an existing table we would need to use the .transform() trick. Which implies that this should actually be a capability of the various .create() methods, since transform works by creating a new table with those and then copying across the old data.

Here's where .transform() calls .create_table_sql() under the hood:

https://github.com/simonw/sqlite-utils/blob/9388edf57aa15719095e3cf0952c1653cd070c9b/sqlite_utils/db.py#L1627-L1637

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support for generated columns 1160034488  
1065389386 https://github.com/simonw/sqlite-utils/issues/411#issuecomment-1065389386 https://api.github.com/repos/simonw/sqlite-utils/issues/411 IC_kwDOCGYnMM4_gI1K simonw 9599 2022-03-11T18:42:53Z 2022-03-11T21:40:51Z OWNER

The Python API could be: python db[table_name].add_generated_column("field", str, "json_extract(data, '$.field')", stored=True)

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support for generated columns 1160034488  
1065477258 https://github.com/simonw/sqlite-utils/issues/411#issuecomment-1065477258 https://api.github.com/repos/simonw/sqlite-utils/issues/411 IC_kwDOCGYnMM4_geSK eyeseast 25778 2022-03-11T20:14:59Z 2022-03-11T20:14:59Z CONTRIBUTOR

Good call on adding this to create-table, especially for stored columns. Having the stored/virtual split might make this tricky to implement, but I haven't gone any farther than thinking about what the CLI looks like. I'm going to try making the SQL side work first and figure that'll tell me more about what it needs.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support for generated columns 1160034488  
1065458729 https://github.com/simonw/sqlite-utils/issues/411#issuecomment-1065458729 https://api.github.com/repos/simonw/sqlite-utils/issues/411 IC_kwDOCGYnMM4_gZwp simonw 9599 2022-03-11T19:58:50Z 2022-03-11T20:00:25Z OWNER

I'm coming round to your suggestion to have this as extra arguments to sqlite-utils add-column now, especially since you also need to pass a column type.

I'd like to come up with syntax for sqlite-utils create-table as well.

https://sqlite-utils.datasette.io/en/stable/cli-reference.html#create-table

Maybe extra --generated-stored colname expression (and --generated) options would work there.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support for generated columns 1160034488  
1065440445 https://github.com/simonw/sqlite-utils/issues/411#issuecomment-1065440445 https://api.github.com/repos/simonw/sqlite-utils/issues/411 IC_kwDOCGYnMM4_gVS9 simonw 9599 2022-03-11T19:52:15Z 2022-03-11T19:52:15Z OWNER

Two new parameters to .create_table() and friends:

  • generated={...} - generated column definitions
  • generated_stored={...} generated stored column definitions

These columns will be added at the end of the table, but you can use the column_order= parameter to apply a different order.

{
    "total_count": 1,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 1,
    "rocket": 0,
    "eyes": 0
}
Support for generated columns 1160034488  
1065386352 https://github.com/simonw/sqlite-utils/issues/411#issuecomment-1065386352 https://api.github.com/repos/simonw/sqlite-utils/issues/411 IC_kwDOCGYnMM4_gIFw simonw 9599 2022-03-11T18:41:37Z 2022-03-11T18:41:37Z OWNER

I like add-generated-column - feels very clear to me, and is a nice place for adding logic that checks if the DB version supports it or not and shows a useful error.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support for generated columns 1160034488  

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