Spaces:
Sleeping
Sleeping
Upload src/app/executor.py with huggingface_hub
Browse files- src/app/executor.py +13 -0
src/app/executor.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Executor -- chay SQL (da qua sql_validator) tren SQLite, tra ve pandas DataFrame."""
|
| 2 |
+
|
| 3 |
+
import sqlite3
|
| 4 |
+
|
| 5 |
+
import pandas as pd
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def run_query(db_path: str, sql: str) -> pd.DataFrame:
|
| 9 |
+
conn = sqlite3.connect(db_path)
|
| 10 |
+
try:
|
| 11 |
+
return pd.read_sql_query(sql, conn)
|
| 12 |
+
finally:
|
| 13 |
+
conn.close()
|