File size: 5,779 Bytes
5d1a8d2 0c1a3e2 5d1a8d2 0c1a3e2 5d1a8d2 0c1a3e2 5d1a8d2 cfcea40 0c1a3e2 5d1a8d2 cfcea40 0c1a3e2 5d1a8d2 0c1a3e2 cfcea40 0c1a3e2 cfcea40 5d1a8d2 0c1a3e2 5d1a8d2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | {% extends "base.html" %}
{% block title %}Query - SQLite DBaaS{% endblock %}
{% block content %}
<div class="page-header">
<div>
<h1 class="page-title">SQL Query</h1>
<p class="page-subtitle">Execute raw SQL queries</p>
</div>
<a href="/admin/dashboard" class="m3-button m3-button--text">
<span class="material-symbols-outlined">arrow_back</span>
Dashboard
</a>
</div>
<!-- Query Editor -->
<div class="m3-card">
<div class="m3-card-header">
<div class="m3-card-icon">
<span class="material-symbols-outlined">code</span>
</div>
<div>
<div class="m3-card-title">Query Editor</div>
</div>
</div>
<form method="POST" action="/admin/query">
<div class="m3-form-field">
<label class="m3-label" for="sql">SQL Statement</label>
<textarea id="sql" name="sql" class="m3-input m3-textarea" rows="6"
placeholder="SELECT * FROM users LIMIT 10;">{{ sql }}</textarea>
</div>
<div class="m3-button-group">
<button type="submit" class="m3-button m3-button--filled">
<span class="material-symbols-outlined">play_arrow</span>
Run Query
</button>
</div>
</form>
</div>
<!-- Error -->
{% if error %}
<div class="m3-card" style="border-left: 4px solid var(--md-sys-color-error);">
<div class="m3-card-header">
<div class="m3-card-icon" style="background: var(--md-sys-color-error-container); color: var(--md-sys-color-error);">
<span class="material-symbols-outlined">error</span>
</div>
<div>
<div class="m3-card-title" style="color: var(--md-sys-color-error);">Query Error</div>
</div>
</div>
<div class="m3-code-block">{{ error }}</div>
</div>
{% endif %}
<!-- Results -->
{% if results %}
<div class="m3-card">
<div class="m3-card-header">
<div class="m3-card-icon">
<span class="material-symbols-outlined">check_circle</span>
</div>
<div>
<div class="m3-card-title">Results</div>
<div class="m3-card-subtitle">{{ results|length }} rows returned</div>
</div>
</div>
{% if results|length > 0 %}
<div class="m3-table-container" style="max-height: 400px; overflow: auto;">
<table class="m3-table">
<thead>
<tr>
{% for col in columns %}
<th>{{ col }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in results %}
<tr>
{% for col in columns %}
<td class="mono">{{ row[col] if row[col] != None else 'NULL' }}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="empty-state">
<span class="material-symbols-outlined empty-icon">search_off</span>
<div class="empty-title">No results</div>
</div>
{% endif %}
</div>
{% endif %}
<!-- Quick Queries -->
<div class="m3-card">
<div class="m3-card-header">
<div class="m3-card-icon">
<span class="material-symbols-outlined">bolt</span>
</div>
<div>
<div class="m3-card-title">Quick Queries</div>
<div class="m3-card-subtitle">Common operations</div>
</div>
</div>
<div class="quick-actions">
<form method="POST" action="/admin/query" style="display: inline;">
<input type="hidden" name="sql" value="SELECT name FROM sqlite_master WHERE type='table';">
<button type="submit" class="quick-action">
<span class="material-symbols-outlined">table</span>
List Tables
</button>
</form>
<form method="POST" action="/admin/query" style="display: inline;">
<input type="hidden" name="sql" value="PRAGMA integrity_check;">
<button type="submit" class="quick-action">
<span class="material-symbols-outlined">verified</span>
Integrity Check
</button>
</form>
<form method="POST" action="/admin/query" style="display: inline;">
<input type="hidden" name="sql" value="PRAGMA journal_mode;">
<button type="submit" class="quick-action">
<span class="material-symbols-outlined">bolt</span>
Journal Mode
</button>
</form>
<form method="POST" action="/admin/query" style="display: inline;">
<input type="hidden" name="sql" value="SELECT * FROM backup_log ORDER BY created_at DESC LIMIT 10;">
<button type="submit" class="quick-action">
<span class="material-symbols-outlined">history</span>
Recent Backups
</button>
</form>
<form method="POST" action="/admin/query" style="display: inline;">
<input type="hidden" name="sql" value="PRAGMA page_count;">
<button type="submit" class="quick-action">
<span class="material-symbols-outlined">storage</span>
Page Count
</button>
</form>
<form method="POST" action="/admin/query" style="display: inline;">
<input type="hidden" name="sql" value="PRAGMA database_list;">
<button type="submit" class="quick-action">
<span class="material-symbols-outlined">list</span>
Database List
</button>
</form>
</div>
</div>
{% endblock %}
|