home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

8 rows where author_association = "OWNER", "created_at" is on date 2021-01-02 and user = 9599 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

issue 6

  • db.enable_counts() method 2
  • Use _counts to speed up counts 2
  • Support of RData files 1
  • Mechanism for storing metadata in _metadata tables 1
  • Mechanism for maintaining cache of table counts using triggers 1
  • Rename .escape() to .quote() 1

user 1

  • simonw · 8 ✖

author_association 1

  • OWNER · 8 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
753545757 https://github.com/simonw/sqlite-utils/issues/215#issuecomment-753545757 https://api.github.com/repos/simonw/sqlite-utils/issues/215 MDEyOklzc3VlQ29tbWVudDc1MzU0NTc1Nw== simonw 9599 2021-01-02T23:58:07Z 2021-01-02T23:58:07Z OWNER

Thought: maybe there should be a .reset_counts() method too, for if the table gets out of date with the triggers.

One way that could happen is if a table is dropped and recreated - the counts in the _counts table would likely no longer match the number of rows in that table.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Use _counts to speed up counts 777535402  
753545381 https://github.com/simonw/sqlite-utils/issues/215#issuecomment-753545381 https://api.github.com/repos/simonw/sqlite-utils/issues/215 MDEyOklzc3VlQ29tbWVudDc1MzU0NTM4MQ== simonw 9599 2021-01-02T23:52:52Z 2021-01-02T23:52:52Z OWNER

Idea: a db.cached_counts() method that returns a dictionary of data from the _counts table. Call it with a list of tables to get back the counts for just those tables.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Use _counts to speed up counts 777535402  
753544914 https://github.com/simonw/sqlite-utils/issues/217#issuecomment-753544914 https://api.github.com/repos/simonw/sqlite-utils/issues/217 MDEyOklzc3VlQ29tbWVudDc1MzU0NDkxNA== simonw 9599 2021-01-02T23:47:42Z 2021-01-02T23:47:42Z OWNER

https://github.com/simonw/sqlite-utils/blob/9a5c92b63e7917c93cc502478493c51c781b2ecc/sqlite_utils/db.py#L231-L239

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Rename .escape() to .quote() 777543336  
753535488 https://github.com/simonw/sqlite-utils/issues/213#issuecomment-753535488 https://api.github.com/repos/simonw/sqlite-utils/issues/213 MDEyOklzc3VlQ29tbWVudDc1MzUzNTQ4OA== simonw 9599 2021-01-02T22:03:48Z 2021-01-02T22:03:48Z OWNER

I got this error while prototyping this:

too many levels of trigger recursion

It looks like that's because SQLite doesn't like triggers on a table that themselves then update that table - so I'm going to exclude the _counts table from this mechanism.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
db.enable_counts() method 777529979  
753533775 https://github.com/simonw/sqlite-utils/issues/213#issuecomment-753533775 https://api.github.com/repos/simonw/sqlite-utils/issues/213 MDEyOklzc3VlQ29tbWVudDc1MzUzMzc3NQ== simonw 9599 2021-01-02T21:47:10Z 2021-01-02T21:47:10Z OWNER

I'm going to skip virtual tables, which I can identify using this property: https://github.com/simonw/sqlite-utils/blob/1cad7fad3e7a5b734088f5cc545b69a055e636da/sqlite_utils/db.py#L720-L726

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
db.enable_counts() method 777529979  
753524779 https://github.com/simonw/datasette/issues/1168#issuecomment-753524779 https://api.github.com/repos/simonw/datasette/issues/1168 MDEyOklzc3VlQ29tbWVudDc1MzUyNDc3OQ== simonw 9599 2021-01-02T20:19:26Z 2021-01-02T20:19:26Z OWNER

Idea: version the metadata scheme. If the table is called _metadata_v1 it gives me a clear path to designing a new scheme in the future.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Mechanism for storing metadata in _metadata tables 777333388  
753422324 https://github.com/simonw/sqlite-utils/issues/212#issuecomment-753422324 https://api.github.com/repos/simonw/sqlite-utils/issues/212 MDEyOklzc3VlQ29tbWVudDc1MzQyMjMyNA== simonw 9599 2021-01-02T03:00:34Z 2021-01-02T03:00:34Z OWNER

Here's a prototype: python with db.conn: db.conn.executescript(""" CREATE TABLE IF NOT EXISTS [_counts] ([table] TEXT PRIMARY KEY, [count] INTEGER DEFAULT 0); CREATE TRIGGER IF NOT EXISTS [Street_Tree_List_counts_ai] AFTER INSERT ON [Street_Tree_List] BEGIN INSERT OR REPLACE INTO _counts VALUES ('Street_Tree_List', COALESCE( (SELECT count FROM _counts WHERE [table]='Street_Tree_List'), 0) + 1); END; CREATE TRIGGER IF NOT EXISTS [Street_Tree_List_counts_ad] AFTER DELETE ON [Street_Tree_List] BEGIN INSERT OR REPLACE INTO _counts VALUES ('Street_Tree_List', COALESCE( (SELECT count FROM _counts WHERE [table]='Street_Tree_List'), 0) - 1); END; INSERT OR REPLACE INTO _counts VALUES ('Street_Tree_List', (select count(*) from [Street_Tree_List])); """)

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Mechanism for maintaining cache of table counts using triggers 777392020  
753406744 https://github.com/simonw/sqlite-utils/issues/210#issuecomment-753406744 https://api.github.com/repos/simonw/sqlite-utils/issues/210 MDEyOklzc3VlQ29tbWVudDc1MzQwNjc0NA== simonw 9599 2021-01-02T00:02:39Z 2021-01-02T00:02:39Z OWNER

It looks like https://github.com/ofajardo/pyreadr is a good library for this.

I won't add this to sqlite-utils because it's quite a bulky dependency for a relatively small feature.

Normally I'd write a rdata-to-sqlite tool similar to https://pypi.org/project/dbf-to-sqlite/ - but I'm actually working on a new plugin hook for Datasette that might be an even better fit for this. The idea is to allow Datasette plugins to define input formats - such as RData - which would then result in being able to import them on the command-line with datasette insert my.db file.rdata or by uploading a file through the Datasette web interface.

That work is happening over here: https://github.com/simonw/datasette/issues/1160 - I'll close this issue in favour of a sometime-in-the-future datasette-import-rdata plugin.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support of RData files 767685961  

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