Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -44,9 +44,9 @@ def text_to_sql(query):
|
|
44 |
except Exception as e:
|
45 |
return f"Error: {e}"
|
46 |
|
47 |
-
# Function: Execute SQL on SQLite database
|
48 |
def execute_sql(sql_query):
|
49 |
try:
|
|
|
50 |
conn = sqlite3.connect(DB_PATH)
|
51 |
df = pd.read_sql_query(sql_query, conn)
|
52 |
conn.close()
|
@@ -54,6 +54,7 @@ def execute_sql(sql_query):
|
|
54 |
except Exception as e:
|
55 |
return f"SQL Execution Error: {e}"
|
56 |
|
|
|
57 |
# Function: Generate Dynamic Visualization
|
58 |
def visualize_data(df):
|
59 |
if df.empty or df.shape[1] < 2:
|
|
|
44 |
except Exception as e:
|
45 |
return f"Error: {e}"
|
46 |
|
|
|
47 |
def execute_sql(sql_query):
|
48 |
try:
|
49 |
+
sql_query = sql_query.strip().rstrip(";") # Remove trailing semicolons
|
50 |
conn = sqlite3.connect(DB_PATH)
|
51 |
df = pd.read_sql_query(sql_query, conn)
|
52 |
conn.close()
|
|
|
54 |
except Exception as e:
|
55 |
return f"SQL Execution Error: {e}"
|
56 |
|
57 |
+
|
58 |
# Function: Generate Dynamic Visualization
|
59 |
def visualize_data(df):
|
60 |
if df.empty or df.shape[1] < 2:
|