* Add SQL query executor
* Move mermaid.min.js to static asset * Create templates for sql logic
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user