home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

10 rows where issue = 910092577 sorted by updated_at descending

✖
✖

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 2

  • simonw 9
  • eyeseast 1

author_association 2

  • OWNER 9
  • CONTRIBUTOR 1

issue 1

  • Research: syntactic sugar for using --get with SQL queries, maybe "datasette query" · 10 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
1017016553 https://github.com/simonw/datasette/issues/1356#issuecomment-1017016553 https://api.github.com/repos/simonw/datasette/issues/1356 IC_kwDOBm6k_c48nnDp simonw 9599 2022-01-20T01:06:37Z 2022-01-20T01:06:37Z OWNER

A problem with this is that if you're using --query you likely want ALL of the results - at the moment the only Datasette output type that can stream everything is .csv and plugin formats can't handle full streams, see #1062 and #1177.

I figured out a neat pattern for streaming JSON arrays in this TIL: https://til.simonwillison.net/python/output-json-array-streaming

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Research: syntactic sugar for using --get with SQL queries, maybe "datasette query" 910092577  
855282466 https://github.com/simonw/datasette/issues/1356#issuecomment-855282466 https://api.github.com/repos/simonw/datasette/issues/1356 MDEyOklzc3VlQ29tbWVudDg1NTI4MjQ2Ng== simonw 9599 2021-06-05T19:05:06Z 2021-06-05T19:05:06Z OWNER

Yeah that's a good point. I avoided making them sub-commands because datasette serve already supports the multitude of other arguments they also need... but actually that was just me being lazy - I can easily share arguments between multiple functions like I do in sqlite-utils itself: https://github.com/simonw/sqlite-utils/blob/d1a372b3006e6cf7d2017b3ddc484bf5c033e45d/sqlite_utils/cli.py#L46

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Research: syntactic sugar for using --get with SQL queries, maybe "datasette query" 910092577  
853895159 https://github.com/simonw/datasette/issues/1356#issuecomment-853895159 https://api.github.com/repos/simonw/datasette/issues/1356 MDEyOklzc3VlQ29tbWVudDg1Mzg5NTE1OQ== eyeseast 25778 2021-06-03T14:03:59Z 2021-06-03T14:03:59Z CONTRIBUTOR

(Putting thoughts here to keep the conversation in one place.)

I think using datasette for this use-case is the right approach. I usually have both datasette and sqlite-utils installed in the same project, and that's where I'm trying out queries, so it probably makes the most sense to have datasette also manage the output (and maybe the input, too).

It seems like both --get and --query could work better as subcommands, rather than options, if you're looking at building out a full CLI experience in datasette. It would give a cleaner separation in what you're trying to do and let each have its own dedicated options. So something like this:

```sh

run an arbitrary query

datasette query covid.db "select * from ny_times_us_counties limit 1" --format yaml

run a canned query

datasette get covid.db some-canned-query --format yaml ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Research: syntactic sugar for using --get with SQL queries, maybe "datasette query" 910092577  
853566337 https://github.com/simonw/datasette/issues/1356#issuecomment-853566337 https://api.github.com/repos/simonw/datasette/issues/1356 MDEyOklzc3VlQ29tbWVudDg1MzU2NjMzNw== simonw 9599 2021-06-03T05:08:32Z 2021-06-03T05:08:32Z OWNER

Also relevant: CSV streaming for canned queries in #526 - even better if we could stream ANY SQL query.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Research: syntactic sugar for using --get with SQL queries, maybe "datasette query" 910092577  
853565850 https://github.com/simonw/datasette/issues/1356#issuecomment-853565850 https://api.github.com/repos/simonw/datasette/issues/1356 MDEyOklzc3VlQ29tbWVudDg1MzU2NTg1MA== simonw 9599 2021-06-03T05:07:21Z 2021-06-03T05:07:21Z OWNER

A problem with this is that if you're using --query you likely want ALL of the results - at the moment the only Datasette output type that can stream everything is .csv and plugin formats can't handle full streams, see #1062 and #1177.

So there's not much point implementing this unless we first make plugins able to add custom streaming formats.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Research: syntactic sugar for using --get with SQL queries, maybe "datasette query" 910092577  
853562891 https://github.com/simonw/datasette/issues/1356#issuecomment-853562891 https://api.github.com/repos/simonw/datasette/issues/1356 MDEyOklzc3VlQ29tbWVudDg1MzU2Mjg5MQ== simonw 9599 2021-06-03T04:59:40Z 2021-06-03T04:59:40Z OWNER

It's weird that --get is documented on this page right now: https://docs.datasette.io/en/stable/getting_started.html#datasette-get

If I implement this I should build a new "Datasette on the command-line" documentation page to cover both --get and --query.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Research: syntactic sugar for using --get with SQL queries, maybe "datasette query" 910092577  
853560870 https://github.com/simonw/datasette/issues/1356#issuecomment-853560870 https://api.github.com/repos/simonw/datasette/issues/1356 MDEyOklzc3VlQ29tbWVudDg1MzU2MDg3MA== simonw 9599 2021-06-03T04:53:47Z 2021-06-03T04:53:56Z OWNER

This is also interesting when used in conjunction with the proposed datasette insert command from #1163 - Datasette would become a plugin-driven CLI tool for both ingesting and outputting data, as a side-effect of its web features.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Research: syntactic sugar for using --get with SQL queries, maybe "datasette query" 910092577  
853560389 https://github.com/simonw/datasette/issues/1356#issuecomment-853560389 https://api.github.com/repos/simonw/datasette/issues/1356 MDEyOklzc3VlQ29tbWVudDg1MzU2MDM4OQ== simonw 9599 2021-06-03T04:52:13Z 2021-06-03T04:52:13Z OWNER

I should implement #1355 for more efficient --csv streaming as part of this.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Research: syntactic sugar for using --get with SQL queries, maybe "datasette query" 910092577  
853560237 https://github.com/simonw/datasette/issues/1356#issuecomment-853560237 https://api.github.com/repos/simonw/datasette/issues/1356 MDEyOklzc3VlQ29tbWVudDg1MzU2MDIzNw== simonw 9599 2021-06-03T04:51:49Z 2021-06-03T04:51:49Z OWNER

This feels like a relatively simple feature to implement that unlocks a whole new set of possible uses for Datasette - as described by @eyeseast in https://github.com/simonw/sqlite-utils/issues/264#issue-907642546.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Research: syntactic sugar for using --get with SQL queries, maybe "datasette query" 910092577  
853559915 https://github.com/simonw/datasette/issues/1356#issuecomment-853559915 https://api.github.com/repos/simonw/datasette/issues/1356 MDEyOklzc3VlQ29tbWVudDg1MzU1OTkxNQ== simonw 9599 2021-06-03T04:50:52Z 2021-06-03T04:50:52Z OWNER

What happens if you pass multiple databases? The --query would be executed against the first one. And if you pass --crossdb it would be executed against the /_memory database and would support cross-database joins.

Key thing here is that output plugins are supported (also plugins that add new SQL functions), making many Datasette plugins usable from the command-line.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Research: syntactic sugar for using --get with SQL queries, maybe "datasette query" 910092577  

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