import sqlite3
db = sqlite3.connect('database/canifa_ai_dump.sqlite')
db.row_factory = sqlite3.Row
cur = db.cursor()

print("=== pg__dashboard_canifa__chatbot_fashion_rules (mac nha/combo) ===")
cur.execute("""
    SELECT anchor_category, target_category, match_role, occasion_tag 
    FROM pg__dashboard_canifa__chatbot_fashion_rules
    WHERE anchor_category LIKE '%mac nha%' OR anchor_category LIKE '%combo%'
    LIMIT 30
""")
rows = cur.fetchall()
print(f"Found: {len(rows)}")
for r in rows:
    print(" ", dict(r))

print()
print("=== chatbot_fashion_rules (mac nha/combo) ===")
cur.execute("""
    SELECT anchor_category, target_category, match_role, occasion_tag 
    FROM chatbot_fashion_rules
    WHERE anchor_category LIKE '%mac nha%' OR anchor_category LIKE '%combo%'
    LIMIT 30
""")
rows2 = cur.fetchall()
print(f"Found: {len(rows2)}")
for r in rows2:
    print(" ", dict(r))

# Also check what the actual product_line field value is in StarRocks
print()
print("=== Products in StarRocks dump matching 2LA26S004-FA160 ===")
try:
    cur.execute("SELECT * FROM sr__test_db__magento_product_dimension_with_text_embedding WHERE sku = '2LA26S004-FA160' LIMIT 3")
    sr = cur.fetchall()
    if sr:
        for r in sr:
            keys = r.keys()
            print({k: r[k] for k in list(keys)[:15]})
    else:
        print("Not in StarRocks dump")
except Exception as e:
    print("Error:", e)
