# -*- coding: utf-8 -*-
import sys, io, json
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
from sqlalchemy import create_engine, text

pg = create_engine('postgresql://admin:trajet6640@192.168.0.87:5432/apdb_master').connect()

# 안텔민킹 llm_pharm 전체 확인
result = pg.execute(text("""
    SELECT product_name, llm_pharm FROM apc WHERE apc = '0230237810109'
"""))
row = result.fetchone()

print('=== 안텔민킹 llm_pharm 전체 키 ===\n')
data = row.llm_pharm
for k in sorted(data.keys()):
    val = str(data[k])
    if len(val) > 60:
        val = val[:60] + '...'
    print(f'  {k}: {val}')

# 동물약 전체 개수
print('\n=== PostgreSQL 동물약 전체 개수 ===')
result2 = pg.execute(text("SELECT COUNT(*) FROM apc"))
print(f'  전체: {result2.fetchone()[0]}개')

pg.close()
