import sqlite3
import os

db_path = 'build/Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/components.db'

if os.path.exists(db_path):
    conn = sqlite3.connect(db_path)
    cursor = conn.cursor()
    
    # Проверяем таблицы
    cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
    tables = cursor.fetchall()
    print("Tables:", tables)
    
    # Проверяем компоненты
    cursor.execute("SELECT COUNT(*) FROM components")
    components_count = cursor.fetchone()[0]
    print("Components:", components_count)
    
    # Проверяем варианты
    cursor.execute("SELECT COUNT(*) FROM variants")
    variants_count = cursor.fetchone()[0]
    print("Variants:", variants_count)
    
    # Показываем несколько компонентов
    cursor.execute("SELECT designator, id FROM components LIMIT 5")
    components = cursor.fetchall()
    print("Sample components:", components)
    
    # Показываем варианты
    cursor.execute("SELECT name FROM variants")
    variants = cursor.fetchall()
    print("Variants:", variants)
    
    # Проверяем свойства компонентов
    cursor.execute("SELECT COUNT(*) FROM component_properties")
    properties_count = cursor.fetchone()[0]
    print("Component properties:", properties_count)
    
    # Показываем уникальные свойства
    cursor.execute("SELECT DISTINCT property_name FROM component_properties ORDER BY property_name")
    property_names = cursor.fetchall()
    print("Property names:", [p[0] for p in property_names])
    
    # Показываем свойства для первого компонента
    if components:
        first_component_id = components[0][1]
        cursor.execute("SELECT property_name, property_value FROM component_properties WHERE component_id = ?", (first_component_id,))
        first_component_props = cursor.fetchall()
        print(f"Properties for {components[0][0]} (ID: {first_component_id}):", first_component_props)
    
    conn.close()
else:
    print(f"Database file not found: {db_path}") 