home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

8 rows where user = 30934 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

issue 5

  • Document how to send multiple values for "Named parameters" 3
  • Use datasette-table Web Component to guide the design of the JSON API for 1.0 2
  • New pattern for views that return either JSON or HTML, available for plugins 1
  • WIP: Plugin includes 1
  • Add new `"sql_file"` key to Canned Queries in metadata? 1

user 1

  • 20after4 · 8 ✖

author_association 1

  • NONE 8
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
988468238 https://github.com/simonw/datasette/issues/1528#issuecomment-988468238 https://api.github.com/repos/simonw/datasette/issues/1528 IC_kwDOBm6k_c466tQO 20after4 30934 2021-12-08T03:35:45Z 2021-12-08T03:35:45Z NONE

FWIW I implemented something similar with a bit of plugin code:

```python @hookimpl def canned_queries(datasette: Datasette, database: str) -> Mapping[str, str]: # load "canned queries" from the filesystem under # www/sql/db/query_name.sql queries = {}

sqldir = Path(__file__).parent.parent / "sql"
if database:
    sqldir = sqldir / database

if not sqldir.is_dir():
    return queries

for f in sqldir.glob('*.sql'):
    try:
        sql = f.read_text('utf8').strip()
        if not len(sql):
            log(f"Skipping empty canned query file: {f}")
            continue
        queries[f.stem] = { "sql": sql }
    except OSError as err:
        log(err)

return queries

```

{
    "total_count": 1,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 1,
    "rocket": 0,
    "eyes": 0
}
Add new `"sql_file"` key to Canned Queries in metadata? 1060631257  
988463455 https://github.com/simonw/datasette/issues/1304#issuecomment-988463455 https://api.github.com/repos/simonw/datasette/issues/1304 IC_kwDOBm6k_c466sFf 20after4 30934 2021-12-08T03:23:14Z 2021-12-08T03:23:14Z NONE

I actually think it would be a useful thing to add support for in datasette. It wouldn't be difficult to unwind an array of params and add the placeholders automatically.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Document how to send multiple values for "Named parameters"  863884805  
988461884 https://github.com/simonw/datasette/issues/1304#issuecomment-988461884 https://api.github.com/repos/simonw/datasette/issues/1304 IC_kwDOBm6k_c466rs8 20after4 30934 2021-12-08T03:20:26Z 2021-12-08T03:20:26Z NONE

The easiest or most straightforward thing to do is to use named parameters like:

sql select * where key IN (:p1, :p2, :p3)

And simply construct the list of placeholders dynamically based on the number of values.

Doing this is possible with datasette if you forgo "canned queries" and just use the raw query endpoint and pass the query sql, along with p1, p2 ... in the request.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Document how to send multiple values for "Named parameters"  863884805  
982745406 https://github.com/simonw/datasette/issues/1532#issuecomment-982745406 https://api.github.com/repos/simonw/datasette/issues/1532 IC_kwDOBm6k_c46k4E- 20after4 30934 2021-11-30T15:28:57Z 2021-11-30T15:28:57Z NONE

It's a really great API and the documentation is really great too. Honestly, in more than 20 years of professional experience, I haven't worked with any software API that was more of a joy to use.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Use datasette-table Web Component to guide the design of the JSON API for 1.0 1065429936  
981980048 https://github.com/simonw/datasette/issues/1304#issuecomment-981980048 https://api.github.com/repos/simonw/datasette/issues/1304 IC_kwDOBm6k_c46h9OQ 20after4 30934 2021-11-29T20:13:53Z 2021-11-29T20:14:11Z NONE

There isn't any way to do this with sqlite as far as I know. The only option is to insert the right number of ? placeholders into the sql template and then provide an array of values.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Document how to send multiple values for "Named parameters"  863884805  
981966693 https://github.com/simonw/datasette/issues/1532#issuecomment-981966693 https://api.github.com/repos/simonw/datasette/issues/1532 IC_kwDOBm6k_c46h59l 20after4 30934 2021-11-29T19:56:52Z 2021-11-29T19:56:52Z NONE

FWIW I've written some web components that consume the json api and I think it's a really nice way to work with datasette. I like the combination with datasette+sqlite as a back-end feeding data to a front-end that's entirely javascript + html.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Use datasette-table Web Component to guide the design of the JSON API for 1.0 1065429936  
951740637 https://github.com/simonw/datasette/issues/878#issuecomment-951740637 https://api.github.com/repos/simonw/datasette/issues/878 IC_kwDOBm6k_c44umjd 20after4 30934 2021-10-26T09:12:15Z 2021-10-26T09:12:15Z NONE

This sounds really ambitious but also really awesome. I like the idea that basically any piece of a page could be selectively replaced.

It sort of sounds like a python asyncio version of https://github.com/observablehq/runtime

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
New pattern for views that return either JSON or HTML, available for plugins 648435885  
951731255 https://github.com/simonw/datasette/pull/1204#issuecomment-951731255 https://api.github.com/repos/simonw/datasette/issues/1204 IC_kwDOBm6k_c44ukQ3 20after4 30934 2021-10-26T09:01:28Z 2021-10-26T09:01:28Z NONE

Writing the tests will be a bit tricky since we need to confirm that the include_table_top(datasette, database, actor, table) arguments were all passed correctly but the only thing we get back from the plugin is a list of templates. Maybe encode those values into the template names somehow?

Why not return a data structure instead of just a template name?

I've already done some custom hacking to modify datasette but the plugin mechanism you are building here would be much cleaner than what I've built. I'd be happy to help with testing this PR and fleshing it out further if you are still considering merging this.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
WIP: Plugin includes 793002853  

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