2017-10-24 02:56:27 +00:00
|
|
|
{% extends "base.html" %}
|
|
|
|
|
|
|
|
{% block title %}{{ database }}{% endblock %}
|
|
|
|
|
2017-11-12 23:17:00 +00:00
|
|
|
{% block extra_head %}
|
2022-02-02 21:21:11 +00:00
|
|
|
{{- super() -}}
|
2017-12-05 16:17:02 +00:00
|
|
|
{% include "_codemirror.html" %}
|
2017-11-12 23:17:00 +00:00
|
|
|
{% endblock %}
|
|
|
|
|
2017-11-30 07:09:54 +00:00
|
|
|
{% block body_class %}db db-{{ database|to_css_class }}{% endblock %}
|
|
|
|
|
2017-10-24 02:56:27 +00:00
|
|
|
{% block content %}
|
2023-08-11 05:16:19 +00:00
|
|
|
<div class="page-header" style="border-color: #{{ database_color }}">
|
2020-11-02 18:27:25 +00:00
|
|
|
<h1>{{ metadata.title or database }}{% if private %} 🔒{% endif %}</h1>
|
2024-02-25 20:54:16 +00:00
|
|
|
</div>
|
|
|
|
{% set links = database_actions() %}{% if links %}
|
|
|
|
<div class="page-action-menu">
|
|
|
|
<details class="actions-menu-links details-menu">
|
|
|
|
<summary>
|
|
|
|
<div class="icon-text">
|
|
|
|
<svg class="icon" aria-labelledby="actions-menu-links-title" role="img" style="color: #fff" xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 28" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
|
|
<title id="actions-menu-links-title">Database actions</title>
|
|
|
|
<circle cx="12" cy="12" r="3"></circle>
|
|
|
|
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path>
|
|
|
|
</svg>
|
|
|
|
<span>Database actions</span>
|
2020-11-02 18:27:25 +00:00
|
|
|
</div>
|
2024-02-25 20:54:16 +00:00
|
|
|
</summary>
|
|
|
|
<div class="dropdown-menu">
|
|
|
|
<div class="hook"></div>
|
|
|
|
{% if links %}
|
|
|
|
<ul>
|
|
|
|
{% for link in links %}
|
2024-03-07 03:54:06 +00:00
|
|
|
<li><a href="{{ link.href }}">{{ link.label }}
|
|
|
|
{% if link.description %}
|
|
|
|
<p class="dropdown-description">{{ link.description }}</p>
|
|
|
|
{% endif %}</a>
|
|
|
|
</li>
|
2024-02-25 20:54:16 +00:00
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
</details>
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
|
metadata.json support for per-table/per-database metadata
Also added support for descriptions and HTML descriptions.
Here's an example metadata.json file illustrating custom per-database and per-
table metadata:
{
"title": "Overall datasette title",
"description_html": "This is a <em>description with HTML</em>.",
"databases": {
"db1": {
"title": "First database",
"description": "This is a string description & has no HTML",
"license_url": "http://example.com/",
"license": "The example license",
"queries": {
"canned_query": "select * from table1 limit 3;"
},
"tables": {
"table1": {
"title": "Custom title for table1",
"description": "Tables can have descriptions too",
"source": "This has a custom source",
"source_url": "http://example.com/"
}
}
}
}
}
Closes #165, Refs #164
2017-12-07 16:42:54 +00:00
|
|
|
|
2024-01-31 03:54:03 +00:00
|
|
|
{{ top_database() }}
|
|
|
|
|
metadata.json support for per-table/per-database metadata
Also added support for descriptions and HTML descriptions.
Here's an example metadata.json file illustrating custom per-database and per-
table metadata:
{
"title": "Overall datasette title",
"description_html": "This is a <em>description with HTML</em>.",
"databases": {
"db1": {
"title": "First database",
"description": "This is a string description & has no HTML",
"license_url": "http://example.com/",
"license": "The example license",
"queries": {
"canned_query": "select * from table1 limit 3;"
},
"tables": {
"table1": {
"title": "Custom title for table1",
"description": "Tables can have descriptions too",
"source": "This has a custom source",
"source_url": "http://example.com/"
}
}
}
}
}
Closes #165, Refs #164
2017-12-07 16:42:54 +00:00
|
|
|
{% block description_source_license %}{% include "_description_source_license.html" %}{% endblock %}
|
2017-10-24 02:00:37 +00:00
|
|
|
|
2020-06-09 00:05:44 +00:00
|
|
|
{% if allow_execute_sql %}
|
2020-10-20 00:33:59 +00:00
|
|
|
<form class="sql" action="{{ urls.database(database) }}" method="get">
|
2018-05-25 05:50:50 +00:00
|
|
|
<h3>Custom SQL query</h3>
|
2019-07-14 03:38:40 +00:00
|
|
|
<p><textarea id="sql-editor" name="sql">{% if tables %}select * from {{ tables[0].name|escape_sqlite }}{% else %}select sqlite_version(){% endif %}</textarea></p>
|
2019-10-14 03:46:12 +00:00
|
|
|
<p>
|
|
|
|
<button id="sql-format" type="button" hidden>Format SQL</button>
|
|
|
|
<input type="submit" value="Run SQL">
|
|
|
|
</p>
|
2018-05-25 05:50:50 +00:00
|
|
|
</form>
|
|
|
|
{% endif %}
|
2017-11-12 02:35:35 +00:00
|
|
|
|
2021-02-18 22:09:12 +00:00
|
|
|
{% if attached_databases %}
|
|
|
|
<div class="message-info">
|
|
|
|
<p>The following databases are attached to this connection, and can be used for cross-database joins:</p>
|
|
|
|
<ul class="bullets">
|
|
|
|
{% for db_name in attached_databases %}
|
|
|
|
<li><strong>{{ db_name }}</strong> - <a href="?sql=select+*+from+[{{ db_name }}].sqlite_master+where+type='table'">tables</a></li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
|
2022-01-25 18:28:05 +00:00
|
|
|
{% if queries %}
|
|
|
|
<h2 id="queries">Queries</h2>
|
|
|
|
<ul class="bullets">
|
|
|
|
{% for query in queries %}
|
|
|
|
<li><a href="{{ urls.query(database, query.name) }}{% if query.fragment %}#{{ query.fragment }}{% endif %}" title="{{ query.description or query.sql }}">{{ query.title or query.name }}</a>{% if query.private %} 🔒{% endif %}</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% if tables %}
|
|
|
|
<h2 id="tables">Tables</h2>
|
|
|
|
{% endif %}
|
|
|
|
|
2017-11-12 01:50:21 +00:00
|
|
|
{% for table in tables %}
|
2017-11-22 20:12:15 +00:00
|
|
|
{% if show_hidden or not table.hidden %}
|
2017-11-12 01:50:21 +00:00
|
|
|
<div class="db-table">
|
2022-01-25 18:28:05 +00:00
|
|
|
<h3><a href="{{ urls.table(database, table.name) }}">{{ table.name }}</a>{% if table.private %} 🔒{% endif %}{% if table.hidden %}<em> (hidden)</em>{% endif %}</h3>
|
2021-06-06 22:07:45 +00:00
|
|
|
<p><em>{% for column in table.columns %}{{ column }}{% if not loop.last %}, {% endif %}{% endfor %}</em></p>
|
2019-05-02 05:20:24 +00:00
|
|
|
<p>{% if table.count is none %}Many rows{% else %}{{ "{:,}".format(table.count) }} row{% if table.count == 1 %}{% else %}s{% endif %}{% endif %}</p>
|
2017-11-12 01:50:21 +00:00
|
|
|
</div>
|
2017-11-22 20:12:15 +00:00
|
|
|
{% endif %}
|
2017-11-12 01:50:21 +00:00
|
|
|
{% endfor %}
|
|
|
|
|
2017-11-22 20:12:15 +00:00
|
|
|
{% if hidden_count and not show_hidden %}
|
2020-10-20 00:33:59 +00:00
|
|
|
<p>... and <a href="{{ urls.database(database) }}?_show_hidden=1">{{ "{:,}".format(hidden_count) }} hidden table{% if hidden_count == 1 %}{% else %}s{% endif %}</a></p>
|
2017-11-22 20:12:15 +00:00
|
|
|
{% endif %}
|
|
|
|
|
2017-11-12 01:50:21 +00:00
|
|
|
{% if views %}
|
2020-05-27 21:52:03 +00:00
|
|
|
<h2 id="views">Views</h2>
|
2020-10-27 18:40:08 +00:00
|
|
|
<ul class="bullets">
|
2017-11-12 01:50:21 +00:00
|
|
|
{% for view in views %}
|
2020-10-20 00:33:59 +00:00
|
|
|
<li><a href="{{ urls.database(database) }}/{{ view.name|urlencode }}">{{ view.name }}</a>{% if view.private %} 🔒{% endif %}</li>
|
2017-11-12 01:50:21 +00:00
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
{% endif %}
|
|
|
|
|
2019-05-19 20:41:09 +00:00
|
|
|
{% if allow_download %}
|
2024-01-31 03:56:05 +00:00
|
|
|
<p class="download-sqlite">Download SQLite DB: <a href="{{ urls.database(database) }}.db" rel="nofollow">{{ database }}.db</a> <em>{{ format_bytes(size) }}</em></p>
|
2018-05-25 01:12:27 +00:00
|
|
|
{% endif %}
|
2017-11-24 22:41:31 +00:00
|
|
|
|
2017-12-05 16:17:02 +00:00
|
|
|
{% include "_codemirror_foot.html" %}
|
2017-11-15 02:03:00 +00:00
|
|
|
|
2017-10-24 02:56:27 +00:00
|
|
|
{% endblock %}
|