issue_comments
51 rows where author_association = "OWNER" and issue = 849978964 sorted by updated_at descending
This data as json, CSV (advanced)
Suggested facets: created_at (date), updated_at (date)
issue 1
- Show column metadata plus links for foreign keys on arbitrary query results · 51 ✖
id | html_url | issue_url | node_id | user | created_at | updated_at ▲ | author_association | body | reactions | issue | performed_via_github_app |
---|---|---|---|---|---|---|---|---|---|---|---|
1235752140 | https://github.com/simonw/datasette/issues/1293#issuecomment-1235752140 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c5JqBTM | simonw 9599 | 2022-09-02T17:34:09Z | 2022-09-02T17:34:09Z | OWNER | Accidentally closed. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
901475812 | https://github.com/simonw/datasette/issues/1293#issuecomment-901475812 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41u23k | simonw 9599 | 2021-08-18T22:41:19Z | 2021-08-18T22:41:19Z | OWNER |
I'm going to do this, and call the Python library |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
899915829 | https://github.com/simonw/datasette/issues/1293#issuecomment-899915829 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41o6A1 | simonw 9599 | 2021-08-17T01:02:35Z | 2021-08-17T01:02:35Z | OWNER | New approach: this time I'm building a simplified executor for the bytecode operations themselves.
{'registers': {1: ('String', 'hello'),
2: ('Integer', 55),
3: ('rowid', {'table': 0}),
4: ('rowid', {'table': 0}),
5: ('column', {'cursor': 0, 'column_offset': 1}),
6: ('column', {'cursor': 0, 'column_offset': 2}),
7: ('column', {'cursor': 0, 'column_offset': 3})},
'cursors': {0: ('database_table', {'rootpage': 32, 'connection': 0})},
'result_row': [('String', 'hello'),
('Integer', 55),
('rowid', {'table': 0}),
('rowid', {'table': 0}),
('column', {'cursor': 0, 'column_offset': 1}),
('column', {'cursor': 0, 'column_offset': 2}),
('column', {'cursor': 0, 'column_offset': 3})]}
{'registers': {1: ('column', {'cursor': 4, 'column_offset': 0}),
2: ('MakeRecord', {'registers': [0, 1, 2, 3]}),
3: ('column', {'cursor': 0, 'column_offset': 1}),
4: ('column', {'cursor': 3, 'column_offset': 0})},
'cursors': {3: ('ephemeral',
{'num_columns': 1,
'index_keys': [('MakeRecord', {'registers': [0, 1]}),
('MakeRecord', {'registers': [0, 1]}),
('MakeRecord', {'registers': [0, 1, 2, 3]})]}),
2: ('database_table', {'rootpage': 44, 'connection': 0}),
4: ('database_table', {'rootpage': 24, 'connection': 0}),
0: ('database_table', {'rootpage': 42, 'connection': 0})},
'result_row': [('column', {'cursor': 3, 'column_offset': 0})]}
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898961535 | https://github.com/simonw/datasette/issues/1293#issuecomment-898961535 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41lRB_ | simonw 9599 | 2021-08-14T21:37:24Z | 2021-08-14T21:37:24Z | OWNER | Did some more research into building SQLite custom versions via |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898936068 | https://github.com/simonw/datasette/issues/1293#issuecomment-898936068 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41lK0E | simonw 9599 | 2021-08-14T17:44:54Z | 2021-08-14T17:44:54Z | OWNER | Another interesting query to consider: https://latest.datasette.io/fixtures?sql=explain+select+*+from++pragma_table_info%28+%27123_starts_with_digits%27%29 That one shows |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898933865 | https://github.com/simonw/datasette/issues/1293#issuecomment-898933865 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41lKRp | simonw 9599 | 2021-08-14T17:27:16Z | 2021-08-14T17:28:29Z | OWNER | Maybe I split this out into a separate Python library that gets tested against every SQLite release I can possibly try it against, and then bakes out the supported release versions into the library code itself? Datasette could depend on that library. The library could be released independently of Datasette any time a new SQLite version comes out. I could even run a separate git scraper repo that checks for new SQLite releases and submits PRs against the library when a new release comes out. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898913629 | https://github.com/simonw/datasette/issues/1293#issuecomment-898913629 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41lFVd | simonw 9599 | 2021-08-14T16:14:12Z | 2021-08-14T16:14:12Z | OWNER | I would feel a lot more comfortable about all of this if I had a robust mechanism for running the Datasette test suite against multiple versions of SQLite itself. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898913554 | https://github.com/simonw/datasette/issues/1293#issuecomment-898913554 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41lFUS | simonw 9599 | 2021-08-14T16:13:40Z | 2021-08-14T16:13:40Z | OWNER | I think I need to care about the following:
That might be enough. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898788262 | https://github.com/simonw/datasette/issues/1293#issuecomment-898788262 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41kmum | simonw 9599 | 2021-08-14T01:22:26Z | 2021-08-14T01:51:08Z | OWNER | Tried a more complicated query:
0 Init 0 41 0 00 Start at 41 Frustratingly SQLite seems to be able to figure that out just fine, see the column of comments on the right hand side - but I only get those in the Maybe the key to that is this section:
IdxInsert:
IdxLE:
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898760808 | https://github.com/simonw/datasette/issues/1293#issuecomment-898760808 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41kgBo | simonw 9599 | 2021-08-13T23:03:01Z | 2021-08-13T23:03:01Z | OWNER | Another idea: strip out any |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898760020 | https://github.com/simonw/datasette/issues/1293#issuecomment-898760020 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41kf1U | simonw 9599 | 2021-08-13T23:00:28Z | 2021-08-13T23:01:27Z | OWNER | New theory: this is all about 0 Init 0 25 0 00 Start at 25 |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898576097 | https://github.com/simonw/datasette/issues/1293#issuecomment-898576097 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41jy7h | simonw 9599 | 2021-08-13T16:19:57Z | 2021-08-13T16:19:57Z | OWNER | I think I need to look out for After all of that I'll be able to resolve that "table 3" reference. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898572065 | https://github.com/simonw/datasette/issues/1293#issuecomment-898572065 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41jx8h | simonw 9599 | 2021-08-13T16:13:16Z | 2021-08-13T16:13:16Z | OWNER | Aha! That So if the This is really convoluted. I'm no longer confident I can get this to work in a sensible way, especially since I've not started exploring what complex nested tables with CTEs and sub-selects do yet. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898569319 | https://github.com/simonw/datasette/issues/1293#issuecomment-898569319 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41jxRn | simonw 9599 | 2021-08-13T16:09:01Z | 2021-08-13T16:10:48Z | OWNER | Need to figure out what column 2 of that pseudo-table is. I think the answer is here:
In which case column 2 would be But the debug code said "r[8]=state". |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898567974 | https://github.com/simonw/datasette/issues/1293#issuecomment-898567974 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41jw8m | simonw 9599 | 2021-08-13T16:07:00Z | 2021-08-13T16:07:00Z | OWNER | So this line:
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898564705 | https://github.com/simonw/datasette/issues/1293#issuecomment-898564705 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41jwJh | simonw 9599 | 2021-08-13T16:02:12Z | 2021-08-13T16:04:06Z | OWNER | More debug output:
It looks like that
Python code:
``` |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898554859 | https://github.com/simonw/datasette/issues/1293#issuecomment-898554859 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41jtvr | simonw 9599 | 2021-08-13T15:46:18Z | 2021-08-13T15:46:18Z | OWNER | So it looks like the bug is in the code that populates |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898554427 | https://github.com/simonw/datasette/issues/1293#issuecomment-898554427 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41jto7 | simonw 9599 | 2021-08-13T15:45:32Z | 2021-08-13T15:45:32Z | OWNER | Some useful debug output:
Python code:
``` |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898545815 | https://github.com/simonw/datasette/issues/1293#issuecomment-898545815 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41jriX | simonw 9599 | 2021-08-13T15:31:53Z | 2021-08-13T15:31:53Z | OWNER | My hunch here is that registers or columns are being reused in a way that makes my code break - my code is pretty dumb, there are places in it where maybe the first mention of a register wins instead of the last one? |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898541972 | https://github.com/simonw/datasette/issues/1293#issuecomment-898541972 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41jqmU | simonw 9599 | 2021-08-13T15:26:06Z | 2021-08-13T15:29:06Z | OWNER | ResultRow:
Column:
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898541543 | https://github.com/simonw/datasette/issues/1293#issuecomment-898541543 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41jqfn | simonw 9599 | 2021-08-13T15:25:26Z | 2021-08-13T15:25:26Z | OWNER | But the debug output here seems to be saying what we want it to say:
Why then are we seeing |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898540260 | https://github.com/simonw/datasette/issues/1293#issuecomment-898540260 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41jqLk | simonw 9599 | 2021-08-13T15:23:28Z | 2021-08-13T15:23:28Z | OWNER | SorterInsert:
SorterData:
OpenPseudo:
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898536181 | https://github.com/simonw/datasette/issues/1293#issuecomment-898536181 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41jpL1 | simonw 9599 | 2021-08-13T15:17:20Z | 2021-08-13T15:20:33Z | OWNER | Documentation for Running 0 Init 0 15 0 00 Start at 15 0 Init 0 25 0 00 Start at 25 |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898527525 | https://github.com/simonw/datasette/issues/1293#issuecomment-898527525 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41jnEl | simonw 9599 | 2021-08-13T15:08:03Z | 2021-08-13T15:08:03Z | OWNER | Am I going to need to look at the |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898524057 | https://github.com/simonw/datasette/issues/1293#issuecomment-898524057 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41jmOZ | simonw 9599 | 2021-08-13T15:06:37Z | 2021-08-13T15:06:37Z | OWNER | Comparing the |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898519924 | https://github.com/simonw/datasette/issues/1293#issuecomment-898519924 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41jlN0 | simonw 9599 | 2021-08-13T15:03:36Z | 2021-08-13T15:03:36Z | OWNER | Weird edge-case: adding an Without order by this gets it right: With order by: |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898517872 | https://github.com/simonw/datasette/issues/1293#issuecomment-898517872 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41jktw | simonw 9599 | 2021-08-13T15:00:50Z | 2021-08-13T15:00:50Z | OWNER | The primary key column (or type | name | tbl_name | rootpage | sql -- | -- | -- | -- | -- table | simple_primary_key | simple_primary_key | 2 | CREATE TABLE simple_primary_key ( id varchar(30) primary key, content text ) index | sqlite_autoindex_simple_primary_key_1 | simple_primary_key | 3 | |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898506647 | https://github.com/simonw/datasette/issues/1293#issuecomment-898506647 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41jh-X | simonw 9599 | 2021-08-13T14:43:19Z | 2021-08-13T14:43:19Z | OWNER | Work will continue in PR #1434. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813134386 | https://github.com/simonw/datasette/issues/1293#issuecomment-813134386 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzEzNDM4Ng== | simonw 9599 | 2021-04-05T01:20:28Z | 2021-08-13T00:42:30Z | OWNER | ... that output might also provide a better way to extract variables than the current mechanism using a regular expression, by looking for the [UPDATE: it did indeed do that, see #1421] |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898066466 | https://github.com/simonw/datasette/issues/1293#issuecomment-898066466 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41h2gi | simonw 9599 | 2021-08-13T00:40:24Z | 2021-08-13T00:40:24Z | OWNER | It figures out renamed columns too: |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898065948 | https://github.com/simonw/datasette/issues/1293#issuecomment-898065948 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41h2Yc | simonw 9599 | 2021-08-13T00:38:58Z | 2021-08-13T00:38:58Z | OWNER | Trying to run |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898065011 | https://github.com/simonw/datasette/issues/1293#issuecomment-898065011 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41h2Jz | simonw 9599 | 2021-08-13T00:36:30Z | 2021-08-13T00:36:30Z | OWNER |
Here's what it does for that: |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898063815 | https://github.com/simonw/datasette/issues/1293#issuecomment-898063815 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41h13H | simonw 9599 | 2021-08-13T00:33:17Z | 2021-08-13T00:33:17Z | OWNER | Improved version of that function:
```diff diff --git a/datasette/templates/query.html b/datasette/templates/query.html index 75f7f1b..9fe1d4f 100644 --- a/datasette/templates/query.html +++ b/datasette/templates/query.html @@ -67,6 +67,8 @@ </form>+extra_column_info: {{ extra_column_info }} + {% if display_rows %} This data as {% for name, url in renderers.items() %}{{ name }}{{ ", " if not loop.last }}{% endfor %}, CSV <table class="rows-and-columns">
diff --git a/datasette/views/database.py b/datasette/views/database.py
index 7c36034..02f8039 100644
--- a/datasette/views/database.py
+++ b/datasette/views/database.py
@@ -10,6 +10,7 @@ import markupsafe
from datasette.utils import (
await_me_maybe,
check_visibility,
+ columns_for_query,
derive_named_parameters,
to_css_class,
validate_sql_select,
@@ -248,6 +249,8 @@ class QueryView(DataView):
query_error = None
+ extra_column_info = None
+
# Execute query - as write or as read
if write:
if request.method == "POST":
@@ -334,6 +337,10 @@ class QueryView(DataView):
database, sql, params_for_query, truncate=True, **extra_args
)
columns = [r[0] for r in results.description]
+
+ # Try to figure out extra column information
+ db = self.ds.get_database(database)
+ extra_column_info = await db.execute_fn(lambda conn: columns_for_query(conn, sql))
except sqlite3.DatabaseError as e:
query_error = e
results = None
@@ -462,6 +469,7 @@ class QueryView(DataView):
"show_hide_text": show_hide_text,
"show_hide_hidden": markupsafe.Markup(show_hide_hidden),
"hide_sql": hide_sql,
+ "extra_column_info": extra_column_info,
}
return (
``` |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
898056013 | https://github.com/simonw/datasette/issues/1293#issuecomment-898056013 | https://api.github.com/repos/simonw/datasette/issues/1293 | IC_kwDOBm6k_c41hz9N | simonw 9599 | 2021-08-13T00:12:09Z | 2021-08-13T00:12:09Z | OWNER | Having added column metadata in #1430 (ref #942) I could also include a definition list at the top of the query results page exposing the column descriptions for any columns, using the same EXPLAIN mechanism. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813480043 | https://github.com/simonw/datasette/issues/1293#issuecomment-813480043 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzQ4MDA0Mw== | simonw 9599 | 2021-04-05T16:16:17Z | 2021-04-05T16:16:17Z | OWNER | https://latest.datasette.io/fixtures?sql=explain+select+*+from+paginated_view will be an interesting test query - because
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813445512 | https://github.com/simonw/datasette/issues/1293#issuecomment-813445512 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzQ0NTUxMg== | simonw 9599 | 2021-04-05T15:11:40Z | 2021-04-05T15:11:40Z | OWNER | Here's some older example code that works with opcodes from Python, in this case to output indexes used by a query: https://github.com/plasticityai/supersqlite/blob/master/supersqlite/idxchk.py |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813438771 | https://github.com/simonw/datasette/issues/1293#issuecomment-813438771 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzQzODc3MQ== | simonw 9599 | 2021-04-05T14:58:48Z | 2021-04-05T14:58:48Z | OWNER | I may need to do something special for rowid columns - there is a |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813164282 | https://github.com/simonw/datasette/issues/1293#issuecomment-813164282 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzE2NDI4Mg== | simonw 9599 | 2021-04-05T03:42:26Z | 2021-04-05T03:42:36Z | OWNER | Extracting variables with this trick appears to work OK, but you have to pass the correct variables to the ```pycon
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813162622 | https://github.com/simonw/datasette/issues/1293#issuecomment-813162622 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzE2MjYyMg== | simonw 9599 | 2021-04-05T03:34:24Z | 2021-04-05T03:40:35Z | OWNER | This almost works, but throws errors with some queries (anything with a |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813134637 | https://github.com/simonw/datasette/issues/1293#issuecomment-813134637 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzEzNDYzNw== | simonw 9599 | 2021-04-05T01:21:59Z | 2021-04-05T01:21:59Z | OWNER | http://www.sqlite.org/draft/lang_explain.html says:
I'm going to keep exploring this though. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813134227 | https://github.com/simonw/datasette/issues/1293#issuecomment-813134227 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzEzNDIyNw== | simonw 9599 | 2021-04-05T01:19:31Z | 2021-04-05T01:19:31Z | OWNER | | addr | opcode | p1 | p2 | p3 | p4 | p5 | comment | |--------|---------------|------|------|------|-----------------------|------|-----------| | 0 | Init | 0 | 47 | 0 | | 00 | | | 1 | OpenRead | 0 | 51 | 0 | 15 | 00 | | | 2 | Integer | 15 | 2 | 0 | | 00 | | | 3 | Once | 0 | 15 | 0 | | 00 | | | 4 | OpenEphemeral | 2 | 1 | 0 | k(1,) | 00 | | | 5 | VOpen | 1 | 0 | 0 | vtab:3E692C362158 | 00 | | | 6 | String8 | 0 | 5 | 0 | CPAD_2020a_SuperUnits | 00 | | | 7 | SCopy | 7 | 6 | 0 | | 00 | | | 8 | Integer | 2 | 3 | 0 | | 00 | | | 9 | Integer | 2 | 4 | 0 | | 00 | | | 10 | VFilter | 1 | 15 | 3 | | 00 | | | 11 | Rowid | 1 | 8 | 0 | | 00 | | | 12 | MakeRecord | 8 | 1 | 9 | C | 00 | | | 13 | IdxInsert | 2 | 9 | 8 | 1 | 00 | | | 14 | VNext | 1 | 11 | 0 | | 00 | | | 15 | Return | 2 | 0 | 0 | | 00 | | | 16 | Rewind | 2 | 46 | 0 | | 00 | | | 17 | Column | 2 | 0 | 1 | | 00 | | | 18 | IsNull | 1 | 45 | 0 | | 00 | | | 19 | SeekRowid | 0 | 45 | 1 | | 00 | | | 20 | Column | 0 | 2 | 11 | | 00 | | | 21 | Function0 | 1 | 10 | 9 | like(2) | 02 | | | 22 | IfNot | 9 | 45 | 1 | | 00 | | | 23 | Column | 0 | 14 | 13 | | 00 | | | 24 | Function0 | 1 | 12 | 9 | intersects(2) | 02 | | | 25 | Ne | 14 | 45 | 9 | | 51 | | | 26 | Column | 0 | 14 | 9 | | 00 | | | 27 | Function0 | 0 | 9 | 15 | asgeojson(1) | 01 | | | 28 | Rowid | 0 | 16 | 0 | | 00 | | | 29 | Column | 0 | 1 | 17 | | 00 | | | 30 | Column | 0 | 2 | 18 | | 00 | | | 31 | Column | 0 | 3 | 19 | | 00 | | | 32 | Column | 0 | 4 | 20 | | 00 | | | 33 | Column | 0 | 5 | 21 | | 00 | | | 34 | Column | 0 | 6 | 22 | | 00 | | | 35 | Column | 0 | 7 | 23 | | 00 | | | 36 | Column | 0 | 8 | 24 | | 00 | | | 37 | Column | 0 | 9 | 25 | | 00 | | | 38 | Column | 0 | 10 | 26 | | 00 | | | 39 | Column | 0 | 11 | 27 | | 00 | | | 40 | RealAffinity | 27 | 0 | 0 | | 00 | | | 41 | Column | 0 | 12 | 28 | | 00 | | | 42 | Column | 0 | 13 | 29 | | 00 | | | 43 | Column | 0 | 14 | 30 | | 00 | | | 44 | ResultRow | 15 | 16 | 0 | | 00 | | | 45 | Next | 2 | 17 | 0 | | 00 | | | 46 | Halt | 0 | 0 | 0 | | 00 | | | 47 | Transaction | 0 | 0 | 265 | 0 | 01 | | | 48 | Variable | 1 | 31 | 0 | :freedraw | 00 | | | 49 | Function0 | 1 | 31 | 7 | geomfromgeojson(1) | 01 | | | 50 | String8 | 0 | 10 | 0 | %mini% | 00 | | | 51 | Variable | 1 | 32 | 0 | :freedraw | 00 | | | 52 | Function0 | 1 | 32 | 12 | geomfromgeojson(1) | 01 | | | 53 | Integer | 1 | 14 | 0 | | 00 | | | 54 | Goto | 0 | 1 | 0 | | 00 | | Essential documentation for understanding that output: https://www.sqlite.org/opcode.html |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813134072 | https://github.com/simonw/datasette/issues/1293#issuecomment-813134072 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzEzNDA3Mg== | simonw 9599 | 2021-04-05T01:18:37Z | 2021-04-05T01:18:37Z | OWNER | Had a fantastic suggestion on the SQLite forum: it might be possible to get what I want by interpreting the opcodes output by Copying the reply I posted to this thread: That's really useful, thanks! It looks like it might be possible for me to reconstruct where each column came from using the It looks like the opcodes I need to inspect are
The The I think this might work! |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813116177 | https://github.com/simonw/datasette/issues/1293#issuecomment-813116177 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzExNjE3Nw== | simonw 9599 | 2021-04-04T23:31:00Z | 2021-04-04T23:31:00Z | OWNER | Sadly it doesn't do what I need. This query should only return one column, but instead I get back every column that was consulted by the query: |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813115607 | https://github.com/simonw/datasette/issues/1293#issuecomment-813115607 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzExNTYwNw== | simonw 9599 | 2021-04-04T23:25:15Z | 2021-04-04T23:25:15Z | OWNER | Oh wow, I just spotted https://github.com/macbre/sql-metadata
It's for MySQL, PostgreSQL and Hive right now but maybe getting it working with SQLite wouldn't be too hard? |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813115414 | https://github.com/simonw/datasette/issues/1293#issuecomment-813115414 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzExNTQxNA== | simonw 9599 | 2021-04-04T23:23:34Z | 2021-04-04T23:23:34Z | OWNER | The other approach I considered for this was to have my own SQL query parser running in Python, which could pick apart a complex query and figure out which column was sourced from which table. I dropped this idea because it felt that the moment A Python parser approach might be good enough to handle a subset of queries - those that don't use |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813114933 | https://github.com/simonw/datasette/issues/1293#issuecomment-813114933 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzExNDkzMw== | simonw 9599 | 2021-04-04T23:19:22Z | 2021-04-04T23:19:22Z | OWNER | I asked about this on the SQLite forum: https://sqlite.org/forum/forumpost/0180277fb7 |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813113653 | https://github.com/simonw/datasette/issues/1293#issuecomment-813113653 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzExMzY1Mw== | simonw 9599 | 2021-04-04T23:10:49Z | 2021-04-04T23:10:49Z | OWNER | One option I've not fully explored yet: could I write my own custom SQLite C extension which exposes this functionality as a callable function? Then I could load that extension and run a SQL query something like this:
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813113403 | https://github.com/simonw/datasette/issues/1293#issuecomment-813113403 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzExMzQwMw== | simonw 9599 | 2021-04-04T23:08:48Z | 2021-04-04T23:08:48Z | OWNER | Worth noting that adding |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813113218 | https://github.com/simonw/datasette/issues/1293#issuecomment-813113218 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzExMzIxOA== | simonw 9599 | 2021-04-04T23:07:25Z | 2021-04-04T23:07:25Z | OWNER | Here are all of the available constants:
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813113175 | https://github.com/simonw/datasette/issues/1293#issuecomment-813113175 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzExMzE3NQ== | simonw 9599 | 2021-04-04T23:07:01Z | 2021-04-04T23:07:01Z | OWNER | A more promising route I found involved the ```pycon
Then I found a snag:
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 | |
813112546 | https://github.com/simonw/datasette/issues/1293#issuecomment-813112546 | https://api.github.com/repos/simonw/datasette/issues/1293 | MDEyOklzc3VlQ29tbWVudDgxMzExMjU0Ng== | simonw 9599 | 2021-04-04T23:02:45Z | 2021-04-04T23:02:45Z | OWNER | I've done various pieces of research into this over the past few years. Capturing what I've discovered in this ticket. The SQLite C API has functions that can help with this: https://www.sqlite.org/c3ref/column_database_name.html details those. But they're not exposed in the Python SQLite library. Maybe it would be possible to use them via |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Show column metadata plus links for foreign keys on arbitrary query results 849978964 |
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 1