48 lines
1.2 KiB
Python
48 lines
1.2 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('PM_DRUG')
|
|
|
|
print('=== CD_SALEGOODS 테이블 구조 ===\n')
|
|
result = session.execute(text("""
|
|
SELECT COLUMN_NAME, DATA_TYPE
|
|
FROM INFORMATION_SCHEMA.COLUMNS
|
|
WHERE TABLE_NAME = 'CD_SALEGOODS'
|
|
ORDER BY ORDINAL_POSITION
|
|
"""))
|
|
for row in result:
|
|
print(f' {row.COLUMN_NAME}: {row.DATA_TYPE}')
|
|
|
|
print('\n=== CD_SALEGOODS에서 안텔민 검색 ===\n')
|
|
result2 = session.execute(text("""
|
|
SELECT *
|
|
FROM CD_SALEGOODS
|
|
WHERE DrugCode LIKE 'LB00000315%' OR BARCODE LIKE '0230237%'
|
|
"""))
|
|
|
|
rows = list(result2)
|
|
if rows:
|
|
for row in rows:
|
|
print(f'★ 발견!')
|
|
print(f' {dict(row._mapping)}')
|
|
else:
|
|
print('(없음)')
|
|
|
|
print('\n=== CD_SALEGOODS 최근 데이터 (상위 10개) ===\n')
|
|
result3 = session.execute(text("""
|
|
SELECT TOP 10 *
|
|
FROM CD_SALEGOODS
|
|
ORDER BY DrugCode DESC
|
|
"""))
|
|
|
|
for row in result3:
|
|
print(dict(row._mapping))
|
|
|
|
session.close()
|