Spaces:
Sleeping
Sleeping
| {% extends "base.html" %} | |
| {% block title %}Query - SQLite Admin{% endblock %} | |
| {% block content %} | |
| <div class="query-page"> | |
| <div class="page-header"> | |
| <h1>π SQL Query</h1> | |
| <a href="/admin/dashboard" class="btn-secondary">β Back to Dashboard</a> | |
| </div> | |
| <div class="card"> | |
| <form method="POST" action="/admin/query"> | |
| <div class="form-group"> | |
| <label for="sql">SQL Query</label> | |
| <textarea id="sql" name="sql" rows="6" | |
| placeholder="SELECT * FROM users LIMIT 10;">{{ sql }}</textarea> | |
| </div> | |
| <button type="submit" class="btn-primary">Run Query</button> | |
| </form> | |
| </div> | |
| {% if error %} | |
| <div class="card error-card"> | |
| <h2>β Error</h2> | |
| <pre class="error-text">{{ error }}</pre> | |
| </div> | |
| {% endif %} | |
| {% if results %} | |
| <div class="card"> | |
| <h2>β Results ({{ results|length }} rows)</h2> | |
| {% if results|length > 0 %} | |
| <div class="table-scroll"> | |
| <table class="data-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="code">{{ row[col]|truncate(100) if row[col] != None else '<span class="null">NULL</span>' }}</td> | |
| {% endfor %} | |
| </tr> | |
| {% endfor %} | |
| </tbody> | |
| </table> | |
| </div> | |
| {% else %} | |
| <p class="empty-state">No results</p> | |
| {% endif %} | |
| </div> | |
| {% endif %} | |
| <!-- Quick Queries --> | |
| <div class="card"> | |
| <h2>β‘ Quick Queries</h2> | |
| <div class="quick-queries"> | |
| <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="btn-small">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="btn-small">Integrity Check</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="btn-small">Recent Backups</button> | |
| </form> | |
| <form method="POST" action="/admin/query" style="display:inline;"> | |
| <input type="hidden" name="sql" value="PRAGMA journal_mode;"> | |
| <button type="submit" class="btn-small">Journal Mode</button> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| {% endblock %} | |