{% extends "base.html" %} {% import "_catalog_cards.html" as catalog_cards with context %} {% block title %}{{ database }}{% endblock %} {% block extra_head %} {{- super() -}} {% include "_codemirror.html" %} {% include "_sql_parameter_styles.html" %} {% if database_page_data.createTable %} {% endif %} {% endblock %} {% block body_class %}db db-{{ database|to_css_class }}{% endblock %} {% block crumbs %} {{ crumbs.nav(request=request, database=database) }} {% endblock %} {% block recent_item %}{% with recent_type="database", recent_name=database, recent_title=metadata.title, recent_url=urls.database(database) %}{% include "_recent_item.html" %}{% endwith %}{% endblock %} {% block content %} {% set shown_tables = (tables if show_hidden else tables|rejectattr("hidden"))|list %}
{% set action_links, action_title = database_actions(), "Database actions" %} {% include "_action_menu.html" %} {{ top_database() }} {% block description_source_license %}{% include "_description_source_license.html" %}{% endblock %}

{{ "{:,}".format(shown_tables|length) }} table{% if shown_tables|length != 1 %}s{% endif %} {%- if views %}{{ "{:,}".format(views|length) }} view{% if views|length != 1 %}s{% endif %}{% endif -%} {%- if queries %}{{ "{:,}".format(queries_count) }} quer{% if queries_count != 1 %}ies{% else %}y{% endif %}{% endif -%} {%- if size %}{{ format_bytes(size) }}{% endif -%}

{% if allow_execute_sql %}

Custom SQL query

{% set parameter_names = [] %} {% set parameter_values = {} %} {% set sql_parameters_allow_expand = false %} {% include "_sql_parameters.html" %}

{% endif %} {% if attached_databases %}

The following databases are attached to this connection, and can be used for cross-database joins:

{% endif %} {% if queries %}
{% endif %} {% if shown_tables or views %}

Tables{% if views %} and views{% endif %}

Schema →
{% set shown_names = shown_tables|map(attribute="name")|list %} {% call catalog_cards.list() %} {% for table in shown_tables %} {% set linked_tables = (table.foreign_keys.incoming + table.foreign_keys.outgoing)|map(attribute="other_table")|select("in", shown_names)|reject("equalto", table.name)|unique|sort %} {% if table.count is none %}{% set count_text = "Many" %} {% elif table.count_truncated %}{% set count_text = ">" ~ "{:,}".format(table.count - 1) %} {% else %}{% set count_text = "{:,}".format(table.count) %}{% endif %} {{- catalog_cards.card({ "url": urls.table(database, table.name), "name": table.name, "database": database, "type": "table", "private": table.private, "hidden": table.hidden, "count": table.count, "columns": table.columns[:8], "more_columns": table.columns[8:], "column_count": table.columns|length, "has_fts": table.fts_table, "linked_tables": linked_tables, }, count_text=count_text) }} {% endfor %} {% for view in views %} {{- catalog_cards.card({ "url": urls.table(database, view.name), "name": view.name, "type": "view", "private": view.private, }) }} {% endfor %} {% endcall %}
{% endif %} {% if hidden_count and not show_hidden %}

… and {{ "{:,}".format(hidden_count) }} hidden table{% if hidden_count == 1 %}{% else %}s{% endif %}

{% endif %} {% if allow_download %}

Download SQLite DB: {{ database }}.db {{ format_bytes(size) }}

{% endif %}
{% include "_codemirror_foot.html" %} {% include "_sql_parameter_scripts.html" %} {% endblock %}