import sqlite3
import os

db_path = "backend/database/canifa_ai_dump.sqlite"
if not os.path.exists(db_path):
    print(f"DB not found at {db_path}")
    exit(1)

conn = sqlite3.connect(db_path)
cur = conn.cursor()
cur.execute("SELECT name FROM sqlite_master WHERE type='table';")
tables = cur.fetchall()
print("Tables:", [t[0] for t in tables])

# Check distinct values for gender_by_product and age_by_product
table_name = "sr__test_db__magento_product_dimension_with_text_embedding"
try:
    cur.execute(f"SELECT DISTINCT gender_by_product FROM {table_name}")
    genders = cur.fetchall()
    print("Genders:", [g[0] for g in genders])

    cur.execute(f"SELECT DISTINCT age_by_product FROM {table_name}")
    ages = cur.fetchall()
    print("Ages:", [a[0] for a in ages])
except Exception as e:
    print(f"Error querying table {table_name}: {e}")

conn.close()
