Spaces:
Running
Running
comment out erroneous error handling
Browse files
app.py
CHANGED
|
@@ -25,11 +25,9 @@ def sql_engine(query: str) -> str:
|
|
| 25 |
if not rows:
|
| 26 |
return "No results found."
|
| 27 |
|
| 28 |
-
# If query returns a single value (e.g., AVG, SUM, COUNT), return as a string
|
| 29 |
if len(rows) == 1 and len(rows[0]) == 1:
|
| 30 |
return str(rows[0][0]) # Convert numerical result to string
|
| 31 |
|
| 32 |
-
# Convert query results into a clean, readable format
|
| 33 |
return "\n".join([", ".join(map(str, row)) for row in rows])
|
| 34 |
|
| 35 |
except Exception as e:
|
|
@@ -67,8 +65,8 @@ def query_sql(user_query: str) -> str:
|
|
| 67 |
# Log the generated SQL for debugging
|
| 68 |
print(f"Generated SQL: {generated_sql}")
|
| 69 |
|
| 70 |
-
if not generated_sql.strip().lower().startswith(("select", "show", "pragma")):
|
| 71 |
-
return "Error: Only SELECT queries are allowed."
|
| 72 |
|
| 73 |
result = sql_engine(generated_sql)
|
| 74 |
|
|
|
|
| 25 |
if not rows:
|
| 26 |
return "No results found."
|
| 27 |
|
|
|
|
| 28 |
if len(rows) == 1 and len(rows[0]) == 1:
|
| 29 |
return str(rows[0][0]) # Convert numerical result to string
|
| 30 |
|
|
|
|
| 31 |
return "\n".join([", ".join(map(str, row)) for row in rows])
|
| 32 |
|
| 33 |
except Exception as e:
|
|
|
|
| 65 |
# Log the generated SQL for debugging
|
| 66 |
print(f"Generated SQL: {generated_sql}")
|
| 67 |
|
| 68 |
+
# if not generated_sql.strip().lower().startswith(("select", "show", "pragma")):
|
| 69 |
+
# return "Error: Only SELECT queries are allowed."
|
| 70 |
|
| 71 |
result = sql_engine(generated_sql)
|
| 72 |
|