Files
getpgdata/site/templates/query.html
T

64 lines
2.0 KiB
HTML

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SQL-консоль</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
<header>
<h1>SQL-консоль (read-only)</h1>
<nav>
<a href="{{ url_for('index') }}">Главная</a>
<a href="{{ url_for('query') }}">SQL-консоль</a>
</nav>
</header>
<main>
<section class="card">
<form method="post" action="{{ url_for('query') }}">
<textarea name="sql" rows="8" placeholder="SELECT * FROM public.contracts LIMIT 100;">{{ sql }}</textarea>
<button type="submit">Выполнить</button>
<p class="hint">Только SELECT. Обрезается до {{ (QUERY_MAX_ROWS or 200)|int }} строк.</p>
</form>
</section>
{% if error %}
<p class="error">{{ error }}</p>
{% endif %}
{% if columns is not none and not error %}
<section class="card">
<h2>Результат {% if elapsed is not none %}({{ elapsed }} c){% endif %}</h2>
{% if columns %}
<div class="table-wrap">
<table>
<thead>
<tr>{% for c in columns %}<th>{{ c }}</th>{% endfor %}</tr>
</thead>
<tbody>
{% for r in rows %}
<tr>
{% for c in columns %}
<td>
{% if r[c] is none %}<span class="null">NULL</span>
{% elif r[c] is boolean %}{{ 'true' if r[c] else 'false' }}
{% else %}{{ r[c] }}{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
<p class="hint">Строк: {{ rows|length }}</p>
{% else %}
<p>Запрос выполнен без набора строк.</p>
{% endif %}
</section>
{% endif %}
</main>
</body>
</html>