Open simonw opened 10 months ago
I tried this but it didn't seem to work:
diff --git a/datasette_saved_queries/__init__.py b/datasette_saved_queries/__init__.py
index 2d0e13b..f3fb411 100644
--- a/datasette_saved_queries/__init__.py
+++ b/datasette_saved_queries/__init__.py
@@ -1,7 +1,25 @@
from datasette import hookimpl
+import urllib.parse
import sqlite_utils
+@hookimpl
+def database_actions(datasette, database, request):
+ print("database_actions", request)
+ if request.args.get("sql"):
+ return [
+ {
+ "href": datasette.urls.path(
+ "/-/save-query/{}?{}".format(
+ database, urllib.parse.urlencode({
+ "sql": request.args["sql"],
+ })
+ )
+ ),
+ "label": "Save this SQL query",
+ }
+ ]
+
def create_tables(conn):
db = sqlite_utils.Database(conn)
if not db["saved_queries"].exists():
I just added a new Datasette plugin hook that can help with this:
Idea: have an option to save a canned query as private, which means only your actor will be able to view it in the future.
Probably display them with "private" in the name, if that's possible.
That plugin hook is now available in https://github.com/simonw/datasette/releases/tag/1.0a12
This plugin needs a major update, partly based on the needs of Datasette Cloud.
_internal
database (if configured for persistence)