mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
query_actions plugin hook
* New query_actions plugin hook, closes #2283
This commit is contained in:
parent
f99c2f5f8c
commit
6ec0081f5d
7 changed files with 151 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ from datasette.utils.asgi import asgi_send_json, Response
|
|||
import base64
|
||||
import pint
|
||||
import json
|
||||
import urllib
|
||||
|
||||
ureg = pint.UnitRegistry()
|
||||
|
||||
|
|
@ -390,6 +391,23 @@ def table_actions(datasette, database, table, actor):
|
|||
]
|
||||
|
||||
|
||||
@hookimpl
|
||||
def query_actions(datasette, database, query_name, sql):
|
||||
args = {
|
||||
"sql": sql,
|
||||
}
|
||||
if query_name:
|
||||
args["query_name"] = query_name
|
||||
return [
|
||||
{
|
||||
"href": datasette.urls.database(database)
|
||||
+ "/-/explain?"
|
||||
+ urllib.parse.urlencode(args),
|
||||
"label": "Explain this query",
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@hookimpl
|
||||
def database_actions(datasette, database, actor, request):
|
||||
if actor:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue