#!/usr/bin/env python3
"""약재 데이터 확인"""

import sqlite3

conn = sqlite3.connect('kdrug.db')
cur = conn.cursor()

# 확장 정보가 있는 약재 확인
cur.execute("""
    SELECT COUNT(*) FROM herb_master_extended
    WHERE nature IS NOT NULL OR taste IS NOT NULL
""")
extended_count = cur.fetchone()[0]
print(f"확장 정보가 있는 약재: {extended_count}개")

# 효능 태그가 있는 약재 확인
cur.execute("SELECT COUNT(DISTINCT ingredient_code) FROM herb_item_tags")
tagged_count = cur.fetchone()[0]
print(f"효능 태그가 있는 약재: {tagged_count}개")

# 구체적인 데이터 확인
cur.execute("""
    SELECT hme.ingredient_code, hme.herb_name, hme.nature, hme.taste
    FROM herb_master_extended hme
    WHERE hme.nature IS NOT NULL OR hme.taste IS NOT NULL
    LIMIT 5
""")
print("\n확장 정보 샘플:")
for row in cur.fetchall():
    print(f"  - {row[1]} ({row[0]}): {row[2]}/{row[3]}")

# herb_item_tags 데이터 확인
cur.execute("""
    SELECT hit.ingredient_code, het.name, COUNT(*) as count
    FROM herb_item_tags hit
    JOIN herb_efficacy_tags het ON hit.tag_id = het.tag_id
    GROUP BY hit.ingredient_code
    LIMIT 5
""")
print("\n효능 태그 샘플:")
for row in cur.fetchall():
    print(f"  - {row[0]}: {row[2]}개 태그")

conn.close()