Spaces:
Sleeping
Sleeping
feat: Enhance admin rules with file upload, drag-and-drop, chunk processing, and improved UI
a477044
| """ | |
| Quick script to check if admin rules are saved in the database | |
| """ | |
| import sqlite3 | |
| from pathlib import Path | |
| db_path = Path("data/admin_rules.db") | |
| if db_path.exists(): | |
| print(f"β Database found at: {db_path}") | |
| print("\n" + "="*60) | |
| conn = sqlite3.connect(db_path) | |
| conn.row_factory = sqlite3.Row | |
| cursor = conn.cursor() | |
| # Get all rules | |
| cursor.execute("SELECT * FROM admin_rules ORDER BY created_at DESC") | |
| rules = cursor.fetchall() | |
| if rules: | |
| print(f"π Found {len(rules)} rule(s) in database:\n") | |
| for rule in rules: | |
| print(f"Tenant: {rule['tenant_id']}") | |
| print(f"Rule: {rule['rule']}") | |
| print(f"Pattern: {rule['pattern'] or 'N/A'}") | |
| print(f"Severity: {rule['severity']}") | |
| print(f"Enabled: {rule['enabled']}") | |
| print(f"Created: {rule['created_at']}") | |
| print("-" * 60) | |
| else: | |
| print("β οΈ No rules found in database.") | |
| print(" Add rules via the Gradio UI or API to populate the database.") | |
| conn.close() | |
| else: | |
| print(f"β Database not found at: {db_path}") | |
| print(" The database will be created automatically when you add your first rule.") | |
| print("\nπ‘ To add rules:") | |
| print(" 1. Open Gradio UI (python app.py)") | |
| print(" 2. Go to 'Admin Rules & Compliance' tab") | |
| print(" 3. Add rules in the text box and click 'Upload / Append Rules'") | |