* Add SQL query executor
* Move mermaid.min.js to static asset * Create templates for sql logic
This commit is contained in:
7
templates/partials/sql_explorer/schema.html
Normal file
7
templates/partials/sql_explorer/schema.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<div class="overflow-auto" style="max-height: 80vh;">
|
||||
<div class="mermaid" style="opacity: 0;" _="on load
|
||||
mermaid.init(undefined, this)
|
||||
set me.style.opacity to '1'">
|
||||
{{ mermaid_code }}
|
||||
</div>
|
||||
</div>
|
||||
37
templates/partials/sql_explorer/sql_query.html
Normal file
37
templates/partials/sql_explorer/sql_query.html
Normal file
@@ -0,0 +1,37 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user