38 lines
1.4 KiB
HTML
38 lines
1.4 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" spellcheck="false"
|
|
class="w-full h-48 p-4 font-mono text-sm text-gray-800 bg-gray-100 border border-gray-300 rounded-md resize-none focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
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> |