home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

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

issue 1

  • table.pks_and_rows_where() method returning primary keys along with the rows · 7 ✖

author_association 1

  • OWNER 7
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
786037219 https://github.com/simonw/sqlite-utils/issues/240#issuecomment-786037219 https://api.github.com/repos/simonw/sqlite-utils/issues/240 MDEyOklzc3VlQ29tbWVudDc4NjAzNzIxOQ== simonw 9599 2021-02-25T16:39:23Z 2021-02-25T16:39:23Z OWNER

Example from the docs: ```pycon

db = sqlite_utils.Database(memory=True) db["dogs"].insert({"name": "Cleo"}) for pk, row in db["dogs"].pks_and_rows_where(): ... print(pk, row) 1 {'rowid': 1, 'name': 'Cleo'}

db["dogs_with_pk"].insert({"id": 5, "name": "Cleo"}, pk="id") for pk, row in db["dogs_with_pk"].pks_and_rows_where(): ... print(pk, row) 5 {'id': 5, 'name': 'Cleo'}

db["dogs_with_compound_pk"].insert( ... {"species": "dog", "id": 3, "name": "Cleo"}, ... pk=("species", "id") ... ) for pk, row in db["dogs_with_compound_pk"].pks_and_rows_where(): ... print(pk, row) ('dog', 3) {'species': 'dog', 'id': 3, 'name': 'Cleo'} ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.pks_and_rows_where() method returning primary keys along with the rows 816560819  
786036355 https://github.com/simonw/sqlite-utils/issues/240#issuecomment-786036355 https://api.github.com/repos/simonw/sqlite-utils/issues/240 MDEyOklzc3VlQ29tbWVudDc4NjAzNjM1NQ== simonw 9599 2021-02-25T16:38:07Z 2021-02-25T16:38:07Z OWNER

Documentation: https://sqlite-utils.datasette.io/en/latest/python-api.html#listing-rows-with-their-primary-keys

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.pks_and_rows_where() method returning primary keys along with the rows 816560819  
786016380 https://github.com/simonw/sqlite-utils/issues/240#issuecomment-786016380 https://api.github.com/repos/simonw/sqlite-utils/issues/240 MDEyOklzc3VlQ29tbWVudDc4NjAxNjM4MA== simonw 9599 2021-02-25T16:10:01Z 2021-02-25T16:10:01Z OWNER

I prototyped this and I like it: In [1]: import sqlite_utils In [2]: db = sqlite_utils.Database("/Users/simon/Dropbox/Development/datasette/fixtures.db") In [3]: list(db["compound_primary_key"].pks_and_rows_where()) Out[3]: [(('a', 'b'), {'pk1': 'a', 'pk2': 'b', 'content': 'c'})]

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.pks_and_rows_where() method returning primary keys along with the rows 816560819  
786007209 https://github.com/simonw/sqlite-utils/issues/240#issuecomment-786007209 https://api.github.com/repos/simonw/sqlite-utils/issues/240 MDEyOklzc3VlQ29tbWVudDc4NjAwNzIwOQ== simonw 9599 2021-02-25T15:57:50Z 2021-02-25T15:57:50Z OWNER

table.pks_and_rows_where(...) is explicit and I think less ambiguous than the other options.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.pks_and_rows_where() method returning primary keys along with the rows 816560819  
786006794 https://github.com/simonw/sqlite-utils/issues/240#issuecomment-786006794 https://api.github.com/repos/simonw/sqlite-utils/issues/240 MDEyOklzc3VlQ29tbWVudDc4NjAwNjc5NA== simonw 9599 2021-02-25T15:57:17Z 2021-02-25T15:57:28Z OWNER

I quite like pks_with_rows_where(...) - but grammatically it suggests it will return the primary keys that exist where their rows match the criteria - "pks with rows" can be interpreted as "pks for the rows that..." as opposed to "pks accompanied by rows"

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.pks_and_rows_where() method returning primary keys along with the rows 816560819  
786005078 https://github.com/simonw/sqlite-utils/issues/240#issuecomment-786005078 https://api.github.com/repos/simonw/sqlite-utils/issues/240 MDEyOklzc3VlQ29tbWVudDc4NjAwNTA3OA== simonw 9599 2021-02-25T15:54:59Z 2021-02-25T15:56:16Z OWNER

Is pk_rows_where() a good name? It sounds like it returns "primary key rows" which isn't a thing. It actually returns rows along with their primary key.

Other options:

  • table.rows_with_pk_where(...) - should this return (row, pk) rather than (pk, row)?
  • table.rows_where_pk(...)
  • table.pk_and_rows_where(...)
  • table.pk_with_rows_where(...)
  • table.pks_with_rows_where(...) - because rows is pluralized, so pks should be pluralized too?
  • table.pks_rows_where(...)
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.pks_and_rows_where() method returning primary keys along with the rows 816560819  
786001768 https://github.com/simonw/sqlite-utils/issues/240#issuecomment-786001768 https://api.github.com/repos/simonw/sqlite-utils/issues/240 MDEyOklzc3VlQ29tbWVudDc4NjAwMTc2OA== simonw 9599 2021-02-25T15:50:28Z 2021-02-25T15:52:12Z OWNER

One option: .rows_where() could grow a ensure_pk=True option which checks to see if the table is a rowid table and, if it is, includes that in the select.

Or... how about you can call .rows_where(..., pks=True) and it will yield (pk, rowdict) tuple pairs instead of just returning the sequence of dictionaries?

I'm always a little bit nervous of methods that vary their return type based on their arguments. Maybe this would be a separate method instead? python for pk, row in table.pk_rows_where(...): # ...

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.pks_and_rows_where() method returning primary keys along with the rows 816560819  

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