{% extends "flask_deck/base.html" %} {% block content %}

Read-Only SQL Console

SELECT / WITH / EXPLAIN only · rolled-back transaction · auto-redacts sensitive columns · max {{ config.sql_console_max_rows }} rows

READ-ONLY GUARD {% if sql_presets %} Presets: {% for plabel, psql in sql_presets %} {% endfor %} {% endif %}
{% for tbl in tables[:6] %} {% endfor %}
Every execution is audited in the Audit Ledger.
{% if can_save_queries %}

Save & Pin to Dashboard

{% if demo_safe_mode %} {{ deck_icon("lock", 11) }} DEMO LOCKED {% endif %}
{% endif %} {% if saved_queries %}

Saved BI Queries

{{ saved_queries | length }} saved
{% for sq in saved_queries %}
{{ sq.name }} {{ sq.bind_key or 'default' }} {{ sq.chart_type }} {% if sq.is_pinned_to_dashboard %}PINNED{% endif %}
{{ sq.sql[:120] }}
{% if can_save_queries and (is_superuser or sq.owner_id == current_user_id) %}
{% if demo_safe_mode %} {% else %}
{% endif %}
{% endif %}
{% endfor %}
{% endif %} {% if schema_tables %}
Schema Browser ({{ schema_tables | length }} tables)
{% for tbl in schema_tables %}
{% for col in tbl.columns[:10] %}{{ col.name }} ({{ col.type }}){% if not loop.last %}, {% endif %}{% endfor %}
{% endfor %}
{% endif %} {% if chart_svg %}

Query Visualization

{{ chart_type | upper }}
{{ chart_svg }}
{% endif %} {% if result %} {% if result.error %} {% else %}
{{ result.row_count }} row(s) · {{ "%.2f"|format(result.duration_ms) }} ms {% if result.truncated %}TRUNCATED AT {{ config.sql_console_max_rows }}{% endif %} {% if result.redacted_columns %}REDACTED: {{ result.redacted_columns | join(", ") }}{% endif %}
{% for col in result.columns %}{% endfor %} {% for row in result.rows %} {% for cell in row %} {% endfor %} {% else %} {% endfor %}
{{ col }}
{% if cell == '[REDACTED]' %} [REDACTED] {% elif cell is none %} NULL {% else %} {{ cell }} {% endif %}
Query returned 0 rows.
{% endif %} {% endif %}
{% endblock %} {% block extra_scripts %} {% endblock %}