"""
Test the exact query that's failing
"""

import mysql.connector

db_config = {
    "host": "127.0.0.1",
    "user": "root",
    "password": "",
    "database": "event_ai"
}

try:
    conn = mysql.connector.connect(**db_config)
    cursor = conn.cursor(dictionary=True)
    
    print("Testing the exact query from get_dashboard_counts():\n")
    
    # This is the exact query that's failing
    cursor.execute("SELECT COUNT(*) AS total_visitors FROM visitors_registration")
    result = cursor.fetchone()
    print(f"✓ Query succeeded! Total visitors: {result['total_visitors']}")
    
    # Check table structure
    print("\nTable structure:")
    cursor.execute("DESCRIBE visitors_registration")
    columns = cursor.fetchall()
    for col in columns:
        print(f"  {col['Field']} - {col['Type']}")
    
    cursor.close()
    conn.close()

except Exception as e:
    print(f"✗ Error: {e}")
    import traceback
    traceback.print_exc()
