﻿#!/usr/bin/env python
"""Check if Grazuri user table exists and has data"""
import pymysql

conn = pymysql.connect(
    host='localhost',
    user='root',
    password='password',
    database='xygbfpsg_graz',
    charset='utf8mb4'
)

try:
    with conn.cursor() as cursor:
        # Check if user table exists
        cursor.execute("SHOW TABLES LIKE 'user'")
        if cursor.fetchone():
            print("✓ Grazuri 'user' table exists!")
            
            # Count records
            cursor.execute("SELECT COUNT(*) FROM user")
            count = cursor.fetchone()[0]
            print(f"✓ Found {count} users in Grazuri user table")
            
            # Show sample data
            cursor.execute("SELECT userid, name, username, role FROM user LIMIT 10")
            users = cursor.fetchall()
            print("\nSample users:")
            for user in users:
                print(f"  - {user[1]} ({user[2]}) - Role: {user[3]}")
        else:
            print("❌ Grazuri 'user' table does NOT exist")
            print("\nThe SQL file needs to be imported first.")
            
except Exception as e:
    print(f"❌ Error: {str(e)}")
finally:
    conn.close()
