Spaces:
Sleeping
Sleeping
Download check_prompts.py from prithvi55/talk2data: direct link, hf CLI and curl.
- Browser
- Download file 973 Bytes
-
https://huggingface.co/spaces/prithvi55/talk2data/resolve/main/check_prompts.py
- Command line
-
hf download hf://spaces/prithvi55/talk2data/check_prompts.py
-
curl -L -o check_prompts.py https://huggingface.co/spaces/prithvi55/talk2data/resolve/main/check_prompts.py
973 Bytes
| import json | |
| import sqlite3 | |
| PROMPTS_FILE = "prompts.jsonl" | |
| DB_PATH = "business_data.db" # Update if your DB file is different | |
| def check_prompts(prompts_file, db_path): | |
| with open(prompts_file, "r", encoding="utf-8") as f: | |
| lines = f.readlines() | |
| conn = sqlite3.connect(db_path) | |
| cursor = conn.cursor() | |
| for i, line in enumerate(lines, 1): | |
| try: | |
| entry = json.loads(line) | |
| prompt = entry.get("prompt") | |
| sql = entry.get("sql") | |
| cursor.execute(sql) | |
| rows = cursor.fetchall() | |
| if rows: | |
| print(f"[{i}] Prompt: {prompt}\n ✅ Returned {len(rows)} rows.") | |
| else: | |
| print(f"[{i}] Prompt: {prompt}\n ⚠️ No data returned.") | |
| except Exception as e: | |
| print(f"[{i}] Prompt: {prompt}\n ❌ Error: {e}") | |
| conn.close() | |
| if __name__ == "__main__": | |
| check_prompts(PROMPTS_FILE, DB_PATH) |