mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Named canned queries can now be defined in metadata.json like this:
{
"databases": {
"timezones": {
"queries": {
"timezone_for_point": "select tzid from timezones ..."
}
}
}
}
These will be shown in a new "Queries" section beneath "Views" on the database page.
As part of this, I refactored the logic for the database index page. It used
to combine the functionality for listing available tables and the
functionality for executing custom SQL queries in a single template and view.
I have split that template out into database.html and query.html and reworked
the view to more clearly separate the custom SQL executing code.
Refs #20
13 lines
349 B
HTML
13 lines
349 B
HTML
<script>
|
|
var editor = CodeMirror.fromTextArea(document.getElementsByName("sql")[0], {
|
|
lineNumbers: true,
|
|
mode: "text/x-sql",
|
|
lineWrapping: true,
|
|
});
|
|
editor.setOption("extraKeys", {
|
|
"Shift-Enter": function() {
|
|
document.getElementsByClassName("sql")[0].submit();
|
|
},
|
|
Tab: false
|
|
});
|
|
</script>
|