* Add SQL query executor

* Move mermaid.min.js to static asset
* Create templates for sql logic
This commit is contained in:
Peter Stockings
2024-11-06 23:25:25 +11:00
parent 3a07b9d97f
commit 0f55d42f22
9 changed files with 2147 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
class SQLViewer:
class SQLExplorer:
def __init__(self, db_connection_method):
self.execute = db_connection_method
@@ -91,4 +91,21 @@ class SQLViewer:
mermaid_lines.append(relation)
return "\n".join(mermaid_lines)
def execute_sql(self, query):
results = None
columns = []
error = None
try:
# Use your custom execute method
results = self.execute(query)
if results:
# Extract column names from the keys of the first result
columns = list(results[0].keys())
except Exception as e:
error = str(e)
return (results, columns, error)