#!/usr/bin/env python3
"""Script de diagnostic pour vérifier les tables de la base de données."""

import sqlite3
from pathlib import Path

db_path = Path.home() / ".web-sentinel" / "auth.db"
print(f"🔍 Diagnostic base de données : {db_path}")

with sqlite3.connect(db_path) as conn:
    # Lister toutes les tables
    cursor = conn.execute("SELECT name FROM sqlite_master WHERE type='table';")
    tables = [row[0] for row in cursor.fetchall()]
    print(f"📊 Tables existantes : {tables}")
    
    # Vérifier table user_subscriptions
    if "user_subscriptions" in tables:
        print("\n✅ Table user_subscriptions existe")
        cursor = conn.execute("SELECT * FROM user_subscriptions;")
        rows = cursor.fetchall()
        print(f"📝 Nombre d'entrées : {len(rows)}")
        for row in rows:
            print(f"  📋 {row}")
    else:
        print("\n❌ Table user_subscriptions inexistante")
        
    # Vérifier utilisateurs existants
    print("\n👥 Utilisateurs dans table users :")
    cursor = conn.execute("SELECT id, email, username FROM users;")
    for row in cursor.fetchall():
        print(f"  👤 {row}")