{% extends "base.html" %} {% block title %}{{ database }}{% if query and query.sql %}: {{ query.sql }}{% endif %}{% endblock %} {% block extra_head %} {{- super() -}} {% if columns %} {% endif %} {% if query_page_data %} {% include "_column_stats_loader.html" %} {% endif %} {% include "_codemirror.html" %} {% include "_sql_parameter_styles.html" %} {% endblock %} {% block body_class %}query db-{{ database|to_css_class }}{% if stored_query %} query-{{ stored_query|to_css_class }}{% endif %}{% endblock %} {% block crumbs %} {{ crumbs.nav(request=request, database=database) }} {% endblock %} {% block recent_item %}{% if stored_query %}{% with recent_type="query", recent_name=stored_query, recent_title=metadata.title, recent_url=urls.query(database, stored_query) %}{% include "_recent_item.html" %}{% endwith %}{% endif %}{% endblock %} {% block content %} {% if stored_query_write and db_is_immutable %}

This query cannot be executed because the database is immutable.

{% endif %}

{{ metadata.title or database }}{% if stored_query and not metadata.title %}: {{ stored_query }}{% endif %}{% if private %} 🔒{% endif %}

{% set action_links, action_title = query_actions(), "Query actions" %} {% include "_action_menu.html" %} {% if stored_query %}{{ top_stored_query() }}{% else %}{{ top_query() }}{% endif %} {% block description_source_license %}{% include "_description_source_license.html" %}{% endblock %}

Custom SQL query{% if display_rows %} returning {% if truncated %}more than {% endif %}{{ "{:,}".format(display_rows|length) }} row{% if display_rows|length == 1 %}{% else %}s{% endif %}{% endif %}{% if not query_error %} ({{ show_hide_text }}) {% endif %}

{% if error %}

{{ error }}

{% endif %} {% if not hide_sql %} {% if editable and allow_execute_sql %}

{% else %}
{% if query %}{{ query.sql }}{% endif %}
{% endif %} {% else %} {% if not stored_query %} {% endif %} {% endif %} {% set parameter_names = named_parameter_values.keys()|list %} {% set parameter_values = named_parameter_values %} {% set sql_parameters_allow_expand = false %} {% include "_sql_parameters.html" %}

{% if not hide_sql %}{% endif %} {{ show_hide_hidden }} {% if save_query_url %}Save this query{% endif %} {% if stored_query and edit_sql_url %}Edit SQL{% endif %}

{% if display_rows %}
{% include "_export_button.html" %}
{% set export_meta, export_scope = stored_query or database, "Query results" %} {% set export_scope_description %}{% if stored_query %}from the {{ stored_query }} query{% else %}from this SQL query{% endif %}{% for name, value in named_parameter_values.items() %}{{ " with " if loop.first else ", " }}{{ name }} = "{{ value }}"{% endfor %}{% endset %} {#- Queries are not paginated: every format returns the rows shown here -#} {% set export_rows = { "page": display_rows|length, "more": true if truncated else false, "later": false, "max": display_rows|length, "total": none, "count_url": none, } %} {% include "_export_dialog.html" %} {% endif %} {% set show_zero_results = not stored_query_write and not error %} {% include "_query_results.html" %} {% include "_codemirror_foot.html" %} {% include "_sql_parameter_scripts.html" %} {% endblock %}