# -*- coding: utf-8 -*-
from sqlalchemy import create_engine, text

engine = create_engine('postgresql://admin:trajet6640@192.168.0.87:5432/apdb_master')
with engine.connect() as conn:
    # 오리더밀 검색
    result = conn.execute(text("""
        SELECT apc, product_name, item_seq, 
               llm_pharm->>'분류' as category,
               llm_pharm->>'간이분류' as easy_category,
               image_url1
        FROM apc 
        WHERE product_name ILIKE '%오리더밀%'
        ORDER BY apc
    """))
    
    print('=== PostgreSQL 오리더밀 검색 결과 ===')
    for row in result:
        print(f'APC: {row.apc}')
        print(f'  제품명: {row.product_name}')
        print(f'  item_seq: {row.item_seq}')
        print(f'  분류: {row.category}')
        print(f'  간이분류: {row.easy_category}')
        print(f'  이미지: {row.image_url1}')
        print()
