54 lines
1.4 KiB
Python
54 lines
1.4 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('=== PM_DRUG 전체 테이블 목록 ===\n')
|
|
|
|
result = session.execute(text("""
|
|
SELECT TABLE_NAME
|
|
FROM INFORMATION_SCHEMA.TABLES
|
|
WHERE TABLE_TYPE = 'BASE TABLE'
|
|
ORDER BY TABLE_NAME
|
|
"""))
|
|
|
|
for row in result:
|
|
print(row.TABLE_NAME)
|
|
|
|
print('\n=== BARCODE 관련 컬럼이 있는 테이블 ===\n')
|
|
|
|
result2 = session.execute(text("""
|
|
SELECT TABLE_NAME, COLUMN_NAME
|
|
FROM INFORMATION_SCHEMA.COLUMNS
|
|
WHERE COLUMN_NAME LIKE '%BARCODE%' OR COLUMN_NAME LIKE '%BAR%'
|
|
ORDER BY TABLE_NAME
|
|
"""))
|
|
|
|
for row in result2:
|
|
print(f'{row.TABLE_NAME}.{row.COLUMN_NAME}')
|
|
|
|
print('\n=== LB000003157 이 들어있는 테이블 찾기 ===\n')
|
|
|
|
# 주요 테이블들에서 검색
|
|
tables_to_check = ['CD_GOODS', 'CD_BARCODE', 'CD_ETCGOODS', 'TEMP_ETCGOODS']
|
|
|
|
for tbl in tables_to_check:
|
|
try:
|
|
result = session.execute(text(f"""
|
|
SELECT TOP 1 * FROM {tbl} WHERE DrugCode = 'LB000003157' OR DRUGCODE = 'LB000003157'
|
|
"""))
|
|
row = result.fetchone()
|
|
if row:
|
|
print(f'★ {tbl}: 발견!')
|
|
print(f' {dict(row._mapping)}')
|
|
except Exception as e:
|
|
pass
|
|
|
|
session.close()
|