59 lines
1.7 KiB
Python
59 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
import sys
|
|
import io
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
|
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('anipharmacopeia')
|
|
|
|
# 안텔민킹 APC로 검색
|
|
apc = '0230237810109'
|
|
|
|
print(f'=== PostgreSQL에서 APC {apc} 조회 ===\n')
|
|
|
|
# anipharmacopeia 테이블 확인
|
|
result = session.execute(text("""
|
|
SELECT * FROM anipharmacopeia
|
|
WHERE apc = :apc
|
|
"""), {'apc': apc})
|
|
|
|
row = result.fetchone()
|
|
if row:
|
|
print('★ 발견!\n')
|
|
cols = result.keys()
|
|
for col in cols:
|
|
val = getattr(row, col)
|
|
if val:
|
|
print(f' {col}: {val}')
|
|
else:
|
|
print('(없음)')
|
|
|
|
# 개/고양이 관련 컬럼 확인
|
|
print('\n=== 개/고양이 관련 컬럼 확인 ===\n')
|
|
result2 = session.execute(text("""
|
|
SELECT column_name, data_type
|
|
FROM information_schema.columns
|
|
WHERE table_name = 'anipharmacopeia'
|
|
AND (column_name LIKE '%dog%' OR column_name LIKE '%cat%'
|
|
OR column_name LIKE '%canine%' OR column_name LIKE '%feline%'
|
|
OR column_name LIKE '%animal%' OR column_name LIKE '%species%'
|
|
OR column_name LIKE '%target%' OR column_name LIKE '%use%')
|
|
"""))
|
|
for r in result2:
|
|
print(f' {r.column_name}: {r.data_type}')
|
|
|
|
# 전체 컬럼 목록
|
|
print('\n=== 전체 컬럼 목록 ===\n')
|
|
result3 = session.execute(text("""
|
|
SELECT column_name FROM information_schema.columns
|
|
WHERE table_name = 'anipharmacopeia'
|
|
ORDER BY ordinal_position
|
|
"""))
|
|
for r in result3:
|
|
print(f' {r.column_name}')
|
|
|
|
session.close()
|