Files
workout/templates/partials/sql_explorer/sql_query.html
Peter Stockings 0f55d42f22 * Add SQL query executor
* Move mermaid.min.js to static asset
* Create templates for sql logic
2024-11-06 23:25:25 +11:00

37 lines
1.2 KiB
HTML

<div id="sql-query">
{% if error %}
<div class="bg-red-200 text-red-800 p-3 rounded mb-4">
<strong>Error:</strong> {{ error }}
</div>
{% endif %}
<form method="POST" hx-post="{{ url_for('sql_query') }}" hx-target="#sql-query">
<textarea name="query" rows="5" class="w-full p-2 border rounded mb-4"
placeholder="Enter your SQL query here..." required>{{ query }}</textarea>
<button type="submit" class="bg-blue-500 text-white px-4 py-2 rounded">Execute</button>
</form>
<div class="mt-6">
{% if results %}
<table class="min-w-full bg-white">
<thead>
<tr>
{% for col in columns %}
<th class="py-2 px-4 border-b">{{ col }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in results %}
<tr class="text-center">
{% for col in columns %}
<td class="py-2 px-4 border-b">{{ row[col] }}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
</div>