getpgdata: Flask-приложение для доступа к PostgreSQL (Nubes структура)
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Ошибка {{ code }}</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<header><h1>Ошибка {{ code }}</h1></header>
|
||||
<main>
|
||||
<p class="error">{{ message }}</p>
|
||||
<p><a href="{{ url_for('index') }}">← На главную</a></p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,62 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>PostgreSQL Access</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>PostgreSQL Access</h1>
|
||||
<nav>
|
||||
<a href="{{ url_for('index') }}">Главная</a>
|
||||
<a href="{{ url_for('query') }}">SQL-консоль</a>
|
||||
</nav>
|
||||
{% if env == 'test' %}<span class="badge test">TEST</span>{% endif %}
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<section class="card">
|
||||
<h2>Подключение</h2>
|
||||
<table class="kv">
|
||||
<tr><th>Host</th><td>{{ cfg.host }}</td></tr>
|
||||
<tr><th>Port</th><td>{{ cfg.port }}</td></tr>
|
||||
<tr><th>Database</th><td>{{ cfg.dbname }}</td></tr>
|
||||
<tr><th>User</th><td>{{ cfg.user }}</td></tr>
|
||||
</table>
|
||||
{% if error %}
|
||||
<p class="error">{{ error }}</p>
|
||||
{% else %}
|
||||
<p class="ok">✓ Подключение активно</p>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
{% if tables is not none and not error %}
|
||||
<section class="card">
|
||||
<h2>Таблицы ({{ tables|length }})</h2>
|
||||
{% if tables %}
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Схема</th><th>Таблица</th><th></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for t in tables %}
|
||||
<tr>
|
||||
<td>{{ t.schemaname }}</td>
|
||||
<td>{{ t.tablename }}</td>
|
||||
<td>
|
||||
<a href="{{ url_for('table', schema=t.schemaname, name=t.tablename) }}">открыть</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p>Доступных таблиц нет.</p>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endif %}
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,63 @@
|
||||
<!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>
|
||||
@@ -0,0 +1,62 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Таблица — {{ schema }}.{{ name }}</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Таблица: {{ schema }}.{{ name }}</h1>
|
||||
<nav>
|
||||
<a href="{{ url_for('index') }}">Главная</a>
|
||||
<a href="{{ url_for('query') }}">SQL-консоль</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
{% if error %}
|
||||
<p class="error">{{ error }}</p>
|
||||
{% else %}
|
||||
<p>Строк всего: <strong>{{ count }}</strong>. Показано: {{ rows|length }} (стр. {{ page }}).</p>
|
||||
|
||||
{% 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>
|
||||
|
||||
<nav class="pager">
|
||||
{% if page > 1 %}
|
||||
<a href="{{ url_for('table', schema=schema, name=name, page=page-1, per_page=per_page) }}">← Назад</a>
|
||||
{% endif %}
|
||||
{% if page * per_page < count %}
|
||||
<a href="{{ url_for('table', schema=schema, name=name, page=page+1, per_page=per_page) }}">Вперёд →</a>
|
||||
{% endif %}
|
||||
</nav>
|
||||
{% else %}
|
||||
<p>Таблица пуста.</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user