# -*- coding: utf-8 -*-
import sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
sys.path.insert(0, 'c:\\Users\\청춘약국\\source\\pharmacy-pos-qr-system\\backend')

from db.dbsetup import get_db_session
from sqlalchemy import text

session = get_db_session('PM_DRUG')

print('1. 현재 상태 확인...')
result = session.execute(text("""
    SELECT DrugCode, GoodsName, POS_BOON 
    FROM CD_GOODS 
    WHERE DrugCode = 'LB000003140'
"""))
row = result.fetchone()
print(f'   {row.GoodsName}: POS_BOON = {row.POS_BOON}')

print('\n2. POS_BOON을 동물약(010103)으로 업데이트...')
try:
    session.execute(text("""
        UPDATE CD_GOODS 
        SET POS_BOON = '010103'
        WHERE DrugCode = 'LB000003140'
    """))
    session.commit()
    print('   ✅ 성공!')
    
    # 확인
    result2 = session.execute(text("""
        SELECT DrugCode, GoodsName, POS_BOON 
        FROM CD_GOODS 
        WHERE DrugCode = 'LB000003140'
    """))
    row2 = result2.fetchone()
    print(f'   {row2.GoodsName}: POS_BOON = {row2.POS_BOON}')
    
except Exception as e:
    session.rollback()
    print(f'   ❌ 실패: {e}')

session.close()
