home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

21 rows where "created_at" is on date 2022-10-30 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

issue 6

  • Ensure insert API has good tests for rowid and compound primark key tables 8
  • API explorer tool 6
  • SITE-BUSTING ERROR: "render_template() called before await ds.invoke_startup()" 3
  • Delete a single record from an existing table 2
  • Make `cursor.rowcount` accessible (wontfix) 1
  • API to drop a table 1

user 2

  • simonw 19
  • mroswell 2

author_association 2

  • OWNER 19
  • CONTRIBUTOR 2
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
1296375536 https://github.com/simonw/datasette/issues/1864#issuecomment-1296375536 https://api.github.com/repos/simonw/datasette/issues/1864 IC_kwDOBm6k_c5NRR7w simonw 9599 2022-10-30T23:17:11Z 2022-10-30T23:17:11Z OWNER

I'm a bit nervous about calling .delete() with the pk_values - can I be sure they are in the correct order? https://github.com/simonw/datasette/blob/00632ded30e7cf9f0cf9478680645d1dabe269ae/datasette/views/row.py#L188-L190

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Delete a single record from an existing table 1425029275  
1296375310 https://github.com/simonw/datasette/issues/1864#issuecomment-1296375310 https://api.github.com/repos/simonw/datasette/issues/1864 IC_kwDOBm6k_c5NRR4O simonw 9599 2022-10-30T23:16:19Z 2022-10-30T23:16:19Z OWNER

Still needs tests that cover compound primary keys and rowid tables.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Delete a single record from an existing table 1425029275  
1296363981 https://github.com/simonw/datasette/issues/1874#issuecomment-1296363981 https://api.github.com/repos/simonw/datasette/issues/1874 IC_kwDOBm6k_c5NRPHN simonw 9599 2022-10-30T22:19:47Z 2022-10-30T22:19:47Z OWNER

Documentation: https://docs.datasette.io/en/1.0-dev/json_api.html#dropping-tables

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API to drop a table 1429030341  
1296358636 https://github.com/simonw/sqlite-utils/issues/506#issuecomment-1296358636 https://api.github.com/repos/simonw/sqlite-utils/issues/506 IC_kwDOCGYnMM5NRNzs simonw 9599 2022-10-30T21:52:11Z 2022-10-30T21:52:11Z OWNER

This could work in a similar way to db.insert(...).last_rowid.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make `cursor.rowcount` accessible (wontfix) 1429029604  
1296343716 https://github.com/simonw/datasette/issues/1873#issuecomment-1296343716 https://api.github.com/repos/simonw/datasette/issues/1873 IC_kwDOBm6k_c5NRKKk simonw 9599 2022-10-30T20:24:55Z 2022-10-30T20:24:55Z OWNER

I think the key feature I need here is going to be the equivalent of ignore=True and replace=True for dealing with primary key collisions, see https://sqlite-utils.datasette.io/en/stable/reference.html#sqlite_utils.db.Table.insert

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ensure insert API has good tests for rowid and compound primark key tables 1428630253  
1296343317 https://github.com/simonw/datasette/issues/1873#issuecomment-1296343317 https://api.github.com/repos/simonw/datasette/issues/1873 IC_kwDOBm6k_c5NRKEV simonw 9599 2022-10-30T20:22:40Z 2022-10-30T20:22:40Z OWNER

So maybe they're not actually worth worrying about separately, because they are guaranteed to have a primary key set.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ensure insert API has good tests for rowid and compound primark key tables 1428630253  
1296343173 https://github.com/simonw/datasette/issues/1873#issuecomment-1296343173 https://api.github.com/repos/simonw/datasette/issues/1873 IC_kwDOBm6k_c5NRKCF simonw 9599 2022-10-30T20:21:54Z 2022-10-30T20:22:20Z OWNER

One last case to consider: WITHOUT ROWID tables.

https://www.sqlite.org/withoutrowid.html

By default, every row in SQLite has a special column, usually called the "rowid", that uniquely identifies that row within the table. However if the phrase "WITHOUT ROWID" is added to the end of a CREATE TABLE statement, then the special "rowid" column is omitted. There are sometimes space and performance advantages to omitting the rowid.

...

Every WITHOUT ROWID table must have a PRIMARY KEY. An error is raised if a CREATE TABLE statement with the WITHOUT ROWID clause lacks a PRIMARY KEY.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ensure insert API has good tests for rowid and compound primark key tables 1428630253  
1296343014 https://github.com/simonw/datasette/issues/1873#issuecomment-1296343014 https://api.github.com/repos/simonw/datasette/issues/1873 IC_kwDOBm6k_c5NRJ_m simonw 9599 2022-10-30T20:21:01Z 2022-10-30T20:21:01Z OWNER

Actually, for simplicity I'm going to say that you can always set the primary key, even for auto-incrementing primary key columns... but you cannot set it on pure rowid columns.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ensure insert API has good tests for rowid and compound primark key tables 1428630253  
1296342814 https://github.com/simonw/datasette/issues/1873#issuecomment-1296342814 https://api.github.com/repos/simonw/datasette/issues/1873 IC_kwDOBm6k_c5NRJ8e simonw 9599 2022-10-30T20:20:05Z 2022-10-30T20:20:05Z OWNER

Some notes on what Datasette does already

https://latest.datasette.io/fixtures/tags.json?_shape=array returns: json [ { "tag": "canine" }, { "tag": "feline" } ] That table is defined like this: sql CREATE TABLE tags ( tag TEXT PRIMARY KEY ); Here's a rowid table with no explicit primary key: https://latest.datasette.io/fixtures/binary_data

https://latest.datasette.io/fixtures/binary_data.json?_shape=array json [ { "rowid": 1, "data": { "$base64": true, "encoded": "FRwCx60F/g==" } }, { "rowid": 2, "data": { "$base64": true, "encoded": "FRwDx60F/g==" } }, { "rowid": 3, "data": null } ] sql CREATE TABLE binary_data ( data BLOB ); https://latest.datasette.io/fixtures/simple_primary_key has a text primary key:

https://latest.datasette.io/fixtures/simple_primary_key.json?_shape=array json [ { "id": "1", "content": "hello" }, { "id": "2", "content": "world" }, { "id": "3", "content": "" }, { "id": "4", "content": "RENDER_CELL_DEMO" }, { "id": "5", "content": "RENDER_CELL_ASYNC" } ] sql CREATE TABLE simple_primary_key ( id varchar(30) primary key, content text ); https://latest.datasette.io/fixtures/compound_primary_key is a compound primary key.

https://latest.datasette.io/fixtures/compound_primary_key.json?_shape=array json [ { "pk1": "a", "pk2": "b", "content": "c" }, { "pk1": "a/b", "pk2": ".c-d", "content": "c" } ] sql CREATE TABLE compound_primary_key ( pk1 varchar(30), pk2 varchar(30), content text, PRIMARY KEY (pk1, pk2) );

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ensure insert API has good tests for rowid and compound primark key tables 1428630253  
1296341469 https://github.com/simonw/datasette/issues/1873#issuecomment-1296341469 https://api.github.com/repos/simonw/datasette/issues/1873 IC_kwDOBm6k_c5NRJnd simonw 9599 2022-10-30T20:13:50Z 2022-10-30T20:13:50Z OWNER

I checked and SQLite itself does allow you to set the rowid on that kind of table - it then increments from whatever you inserted: % sqlite3 /tmp/t.db SQLite version 3.39.4 2022-09-07 20:51:41 Enter ".help" for usage hints. sqlite> create table docs (title text); sqlite> insert into docs (title) values ('one'); sqlite> select rowid, title from docs; 1|one sqlite> insert into docs (rowid, title) values (3, 'three'); sqlite> select rowid, title from docs; 1|one 3|three sqlite> insert into docs (title) values ('another'); sqlite> select rowid, title from docs; 1|one 3|three 4|another

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ensure insert API has good tests for rowid and compound primark key tables 1428630253  
1296341055 https://github.com/simonw/datasette/issues/1873#issuecomment-1296341055 https://api.github.com/repos/simonw/datasette/issues/1873 IC_kwDOBm6k_c5NRJg_ simonw 9599 2022-10-30T20:11:47Z 2022-10-30T20:12:30Z OWNER

If a table has an auto-incrementing primary key, should you be allowed to insert records with an explicit key into it?

I'm torn on this one. It's something you can do with direct database access, but it's something I very rarely want to do.

I'm inclined to disallow it and say that if you want that you can get it using a writable canned query instead.

Likewise, I'm not going to provide a way to set the rowid explicitly on a freshly inserted row.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ensure insert API has good tests for rowid and compound primark key tables 1428630253  
1296339386 https://github.com/simonw/datasette/issues/1871#issuecomment-1296339386 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5NRJG6 simonw 9599 2022-10-30T20:03:04Z 2022-10-30T20:03:04Z OWNER

I do need to skip CSRF for these API calls. I'm going to start out by doing that using the skip_csrf() hook to skip CSRF checks on anything with a content-type: application/json request header.

python @hookimpl def skip_csrf(scope): if scope["type"] == "http": headers = scope.get("headers") if dict(headers).get(b'content-type') == b'application/json': return True

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1296339205 https://github.com/simonw/datasette/issues/1871#issuecomment-1296339205 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5NRJEF simonw 9599 2022-10-30T20:02:05Z 2022-10-30T20:02:05Z OWNER

Realized the API explorer doesn't need the API key piece at all - it can work with standard cookie-based auth.

This also reflects how most plugins are likely to use this API, where they'll be adding JavaScript that uses fetch() to call the write API directly.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1296131872 https://github.com/simonw/datasette/issues/1871#issuecomment-1296131872 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5NQWcg simonw 9599 2022-10-30T06:27:56Z 2022-10-30T06:27:56Z OWNER

Initial prototype API explorer is now live at https://latest-1-0-dev.datasette.io/-/api

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1296131681 https://github.com/simonw/datasette/issues/1873#issuecomment-1296131681 https://api.github.com/repos/simonw/datasette/issues/1873 IC_kwDOBm6k_c5NQWZh simonw 9599 2022-10-30T06:27:12Z 2022-10-30T06:27:12Z OWNER

Relevant TODO: https://github.com/simonw/datasette/blob/c35859ae3df163406f1a1895ccf9803e933b2d8e/datasette/views/table.py#L1131-L1135

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ensure insert API has good tests for rowid and compound primark key tables 1428630253  
1296131343 https://github.com/simonw/datasette/issues/1872#issuecomment-1296131343 https://api.github.com/repos/simonw/datasette/issues/1872 IC_kwDOBm6k_c5NQWUP simonw 9599 2022-10-30T06:26:01Z 2022-10-30T06:26:01Z OWNER

Good spot fixing that!

Sorry about this - it was a change in Datasette 0.63 which should have been better called out.

My goal for Datasette 1.0 (which I aim to have out by the end of the year) is to introduce a formal process for avoiding problems like this, with very clear documentation when something like this might happen.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
SITE-BUSTING ERROR: "render_template() called before await ds.invoke_startup()" 1428560020  
1296130073 https://github.com/simonw/datasette/issues/1871#issuecomment-1296130073 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5NQWAZ simonw 9599 2022-10-30T06:20:56Z 2022-10-30T06:20:56Z OWNER

That initial prototype looks like this:

It currently shows the returned JSON from the API in an alert(). Next I should make that part of the page instead.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1296126389 https://github.com/simonw/datasette/issues/1871#issuecomment-1296126389 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5NQVG1 simonw 9599 2022-10-30T06:04:48Z 2022-10-30T06:04:48Z OWNER

This is even more important now I have pushed: - #1866

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1296114136 https://github.com/simonw/datasette/issues/1871#issuecomment-1296114136 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5NQSHY simonw 9599 2022-10-30T05:15:40Z 2022-10-30T05:15:40Z OWNER

Host it at /-/api

It's an input box with a path in and a textarea you can put JSON in, plus a submit button to post the request.

It lists the API endpoints you can use - click on a link to populate the form field plus a example.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1296080804 https://github.com/simonw/datasette/issues/1872#issuecomment-1296080804 https://api.github.com/repos/simonw/datasette/issues/1872 IC_kwDOBm6k_c5NQJ-k mroswell 192568 2022-10-30T03:06:32Z 2022-10-30T03:06:32Z CONTRIBUTOR

I updated datasette-publish-vercel to 0.14.2 in requirements.txt

And the site is back up!

Is there a way that we can get some sort of notice when something like this will have critical impact on website function?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
SITE-BUSTING ERROR: "render_template() called before await ds.invoke_startup()" 1428560020  
1296076803 https://github.com/simonw/datasette/issues/1872#issuecomment-1296076803 https://api.github.com/repos/simonw/datasette/issues/1872 IC_kwDOBm6k_c5NQJAD mroswell 192568 2022-10-30T02:50:34Z 2022-10-30T02:50:34Z CONTRIBUTOR

should this issue be under https://github.com/simonw/datasette-publish-vercel/issues ?

Perhaps I just need to update: datasette-publish-vercel==0.11 in requirements.txt?

I'll try that and see what happens...

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
SITE-BUSTING ERROR: "render_template() called before await ds.invoke_startup()" 1428560020  

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