issue_comments
8 rows where issue = 1432013704 sorted by updated_at descending
This data as json, CSV (advanced)
Suggested facets: created_at (date), updated_at (date)
issue 1
- /db/table/-/upsert API · 8 ✖
id | html_url | issue_url | node_id | user | created_at | updated_at ▲ | author_association | body | reactions | issue | performed_via_github_app |
---|---|---|---|---|---|---|---|---|---|---|---|
1336100218 | https://github.com/simonw/datasette/issues/1878#issuecomment-1336100218 | https://api.github.com/repos/simonw/datasette/issues/1878 | IC_kwDOBm6k_c5Po0V6 | simonw 9599 | 2022-12-03T07:02:15Z | 2022-12-03T07:02:15Z | OWNER | Moved this work to a PR: - #1931 |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
/db/table/-/upsert API 1432013704 | |
1336094562 | https://github.com/simonw/datasette/issues/1878#issuecomment-1336094562 | https://api.github.com/repos/simonw/datasette/issues/1878 | IC_kwDOBm6k_c5Poy9i | simonw 9599 | 2022-12-03T06:27:50Z | 2022-12-03T06:29:06Z | OWNER | This adds it to the API explorer:
(Made me notice that the way example columns are created for |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
/db/table/-/upsert API 1432013704 | |
1336094470 | https://github.com/simonw/datasette/issues/1878#issuecomment-1336094470 | https://api.github.com/repos/simonw/datasette/issues/1878 | IC_kwDOBm6k_c5Poy8G | simonw 9599 | 2022-12-03T06:27:13Z | 2022-12-03T06:27:13Z | OWNER | Tests are going to need to cover both rowid-only and compound primary key tables, including all of the error states. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
/db/table/-/upsert API 1432013704 | |
1336094381 | https://github.com/simonw/datasette/issues/1878#issuecomment-1336094381 | https://api.github.com/repos/simonw/datasette/issues/1878 | IC_kwDOBm6k_c5Poy6t | simonw 9599 | 2022-12-03T06:26:25Z | 2022-12-03T06:26:25Z | OWNER | Initial prototype: ```diff diff --git a/datasette/app.py b/datasette/app.py index 125b4969..282c0984 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -40,7 +40,7 @@ from .views.special import ( PermissionsDebugView, MessagesDebugView, ) -from .views.table import TableView, TableInsertView, TableDropView +from .views.table import TableView, TableInsertView, TableUpsertView, TableDropView from .views.row import RowView, RowDeleteView, RowUpdateView from .renderer import json_renderer from .url_builder import Urls @@ -1292,6 +1292,10 @@ class Datasette: TableInsertView.as_view(self), r"/(?P<database>[^\/.]+)/(?P<table>[^\/.]+)/-/insert$", ) + add_route( + TableUpsertView.as_view(self), + r"/(?P<database>[^\/.]+)/(?P<table>[^\/.]+)/-/upsert$", + ) add_route( TableDropView.as_view(self), r"/(?P<database>[^\/.]+)/(?P<table>[^\/.]+)/-/drop$", diff --git a/datasette/views/table.py b/datasette/views/table.py index 7ba78c11..ae0d6366 100644 --- a/datasette/views/table.py +++ b/datasette/views/table.py @@ -1074,9 +1074,15 @@ class TableInsertView(BaseView): def init(self, datasette): self.ds = datasette
@@ -1135,6 +1141,15 @@ class TableInsertView(BaseView): # Validate columns of each row columns = set(await db.table_columns(table_name)) for i, row in enumerate(rows): + if upsert: + # It MUST have the primary key + missing_pks = [pk for pk in pks_list if pk not in row] + if missing_pks: + errors.append( + 'Row {} is missing primary key column(s): "{}"'.format( + i, '", "'.join(missing_pks) + ) + ) invalid_columns = set(row.keys()) - columns if invalid_columns: errors.append( @@ -1146,7 +1161,7 @@ class TableInsertView(BaseView): return _errors(errors) return rows, errors, extras
@@ -1172,15 +1192,19 @@ class TableInsertView(BaseView): replace = extras.get("replace")
+class TableUpsertView(TableInsertView):
+ name = "table-upsert"
+
+ async def post(self, request):
+ return await super().post(request, upsert=True)
+
+
class TableDropView(BaseView):
name = "table-drop"
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
/db/table/-/upsert API 1432013704 | |
1336073212 | https://github.com/simonw/datasette/issues/1878#issuecomment-1336073212 | https://api.github.com/repos/simonw/datasette/issues/1878 | IC_kwDOBm6k_c5Potv8 | simonw 9599 | 2022-12-03T05:38:49Z | 2022-12-03T05:38:49Z | OWNER | And on Discord today: https://discord.com/channels/823971286308356157/823971286941302908/1048426072066236536 |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
/db/table/-/upsert API 1432013704 | |
1336070843 | https://github.com/simonw/datasette/issues/1878#issuecomment-1336070843 | https://api.github.com/repos/simonw/datasette/issues/1878 | IC_kwDOBm6k_c5PotK7 | simonw 9599 | 2022-12-03T05:37:53Z | 2022-12-03T05:37:53Z | OWNER | Also requested here: https://news.ycombinator.com/item?id=33839894 |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
/db/table/-/upsert API 1432013704 | |
1312534826 | https://github.com/simonw/datasette/issues/1878#issuecomment-1312534826 | https://api.github.com/repos/simonw/datasette/issues/1878 | IC_kwDOBm6k_c5OO7Eq | stevecrawshaw 18738650 | 2022-11-12T17:34:58Z | 2022-11-12T17:34:58Z | NONE | Hi Simon. I have just started experimenting with datasette in earnest, looking at it's suitability for air quality open data. A bulk upsert \ upsert_all would be very useful for me in enabling real time data to be pushed from a sql server database with FME server to a datasette db. An hourly process queries the last 2 hours of data and pushes that to my database, inserting new data and updating existing combinations of pk siteid and date_time. This is already implemented on our current open data portal. Excited to see your progress with this! Thank you for this amazing software. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
/db/table/-/upsert API 1432013704 | |
1299071456 | https://github.com/simonw/datasette/issues/1878#issuecomment-1299071456 | https://api.github.com/repos/simonw/datasette/issues/1878 | IC_kwDOBm6k_c5NbkHg | simonw 9599 | 2022-11-01T20:02:43Z | 2022-11-01T20:02:43Z | OWNER | Note that "update" is partially covered by the |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
/db/table/-/upsert API 1432013704 |
Advanced export
JSON shape: default, array, newline-delimited, object
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]);
user 2