import sqlite3
from pathlib import Path

# 定义路径
db_path = Path("footviz/data/football.db")

def check_database():
    """检查数据库状态"""
    try:
        # 连接数据库
        conn = sqlite3.connect(db_path)
        cursor = conn.cursor()
        
        # 获取所有表名
        cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
        tables = cursor.fetchall()
        
        print("数据库中的表:")
        for table in tables:
            print(f"  - {table[0]}")
        
        # 获取球队数量
        cursor.execute("SELECT COUNT(*) FROM Teams")
        teams_count = cursor.fetchone()[0]
        print(f"球队数量: {teams_count}")
        
        # 获取球员数量
        cursor.execute("SELECT COUNT(*) FROM Players")
        players_count = cursor.fetchone()[0]
        print(f"球员数量: {players_count}")
        
        # 获取国家数量
        cursor.execute("SELECT COUNT(*) FROM Countries")
        countries_count = cursor.fetchone()[0]
        print(f"国家数量: {countries_count}")
        
        # 获取比赛结果数量
        cursor.execute("SELECT COUNT(*) FROM MatchResults")
        matches_count = cursor.fetchone()[0]
        print(f"比赛结果数量: {matches_count}")
        
        # 获取联赛积分数量
        cursor.execute("SELECT COUNT(*) FROM LeagueStandings")
        standings_count = cursor.fetchone()[0]
        print(f"联赛积分数量: {standings_count}")
        
        # 获取球员统计数据数量
        cursor.execute("SELECT COUNT(*) FROM PlayerStats")
        stats_count = cursor.fetchone()[0]
        print(f"球员统计数据数量: {stats_count}")
        
        conn.close()
        
    except Exception as e:
        print(f"检查数据库时出错: {e}")

if __name__ == "__main__":
    check_database()