- 쌍화탕: 당귀 → 일당귀로 수정 - 월비탕: 진피초 → 진피(陳皮)로 수정 - 십전대보탕: 각 약재별 효능 설명 추가 - 보음보혈, 보혈지통, 대보원기 등 11개 약재 효능 추가 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
112 lines
3.6 KiB
Python
112 lines
3.6 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
십전대보탕 약재별 효능 설명 추가
|
|
"""
|
|
|
|
import sqlite3
|
|
|
|
def update_sipjeondaebotang():
|
|
"""십전대보탕 약재별 효능 설명 업데이트"""
|
|
|
|
conn = sqlite3.connect('database/kdrug.db')
|
|
cursor = conn.cursor()
|
|
|
|
try:
|
|
# 십전대보탕 ID 확인
|
|
cursor.execute("""
|
|
SELECT formula_id, formula_name
|
|
FROM formulas
|
|
WHERE formula_code = 'SJDB01'
|
|
""")
|
|
|
|
result = cursor.fetchone()
|
|
if not result:
|
|
print("❌ 십전대보탕을 찾을 수 없습니다.")
|
|
return False
|
|
|
|
formula_id, formula_name = result
|
|
print(f"📋 {formula_name} (ID: {formula_id}) 효능 설명 추가")
|
|
print("="*60)
|
|
|
|
# 각 약재별 효능 설명 업데이트
|
|
herb_notes = {
|
|
"숙지황": "보음보혈",
|
|
"작약": "보혈지통",
|
|
"인삼": "대보원기",
|
|
"백출": "보기건비",
|
|
"황기": "보기승양",
|
|
"대추": "보중익기",
|
|
"일당귀": "보혈활혈",
|
|
"복령": "건비이수",
|
|
"감초": "조화제약",
|
|
"천궁": "활혈행기",
|
|
"반하생강백반제": "화담지구"
|
|
}
|
|
|
|
print("\n약재별 효능 설명 추가:")
|
|
print("-"*60)
|
|
|
|
for herb_name, notes in herb_notes.items():
|
|
# 약재 코드 찾기
|
|
cursor.execute("""
|
|
SELECT fi.ingredient_id, hm.herb_name, fi.notes
|
|
FROM formula_ingredients fi
|
|
JOIN herb_masters hm ON fi.ingredient_code = hm.ingredient_code
|
|
WHERE fi.formula_id = ? AND hm.herb_name = ?
|
|
""", (formula_id, herb_name))
|
|
|
|
result = cursor.fetchone()
|
|
if result:
|
|
ingredient_id, actual_name, current_notes = result
|
|
|
|
# 효능 설명 업데이트
|
|
cursor.execute("""
|
|
UPDATE formula_ingredients
|
|
SET notes = ?
|
|
WHERE ingredient_id = ?
|
|
""", (notes, ingredient_id))
|
|
|
|
if current_notes:
|
|
print(f" {actual_name}: '{current_notes}' → '{notes}'")
|
|
else:
|
|
print(f" {actual_name}: 효능 설명 추가 → '{notes}'")
|
|
else:
|
|
print(f" ⚠️ {herb_name}: 약재를 찾을 수 없음")
|
|
|
|
conn.commit()
|
|
print(f"\n✅ 효능 설명 추가 완료!")
|
|
|
|
# 업데이트 후 확인
|
|
print(f"\n📊 업데이트된 십전대보탕 구성:")
|
|
print("-"*60)
|
|
|
|
cursor.execute("""
|
|
SELECT hm.herb_name, fi.grams_per_cheop, fi.notes
|
|
FROM formula_ingredients fi
|
|
JOIN herb_masters hm ON fi.ingredient_code = hm.ingredient_code
|
|
WHERE fi.formula_id = ?
|
|
ORDER BY fi.sort_order
|
|
""", (formula_id,))
|
|
|
|
results = cursor.fetchall()
|
|
for herb, amount, notes in results:
|
|
check = "✅" if notes else "❌"
|
|
print(f" {check} {herb:15s}: {amount:5.1f}g - {notes if notes else '효능 설명 없음'}")
|
|
|
|
except sqlite3.Error as e:
|
|
print(f"❌ 데이터베이스 오류: {e}")
|
|
conn.rollback()
|
|
return False
|
|
finally:
|
|
conn.close()
|
|
|
|
return True
|
|
|
|
if __name__ == "__main__":
|
|
print("🌿 십전대보탕 효능 설명 추가 프로그램")
|
|
print("="*60)
|
|
|
|
if update_sipjeondaebotang():
|
|
print("\n✅ 업데이트 작업이 완료되었습니다.")
|
|
else:
|
|
print("\n❌ 업데이트 중 오류가 발생했습니다.") |