""" 특정 거래의 SALE_SUB 데이터 확인 """ import sys import os sys.path.insert(0, os.path.dirname(__file__)) from db.dbsetup import DatabaseManager from sqlalchemy import text def check_sale_sub_data(transaction_id): """특정 거래의 판매 상세 데이터 확인""" db_manager = DatabaseManager() try: session = db_manager.get_session('PM_PRES') # SALE_SUB 모든 컬럼 조회 query = text(""" SELECT * FROM SALE_SUB WHERE SL_NO_order = :transaction_id """) result = session.execute(query, {'transaction_id': transaction_id}).fetchone() if result: print("=" * 80) print(f"거래번호 {transaction_id}의 SALE_SUB 데이터") print("=" * 80) # 모든 컬럼 출력 for key in result._mapping.keys(): value = result._mapping[key] print(f"{key:30} = {value}") print("=" * 80) else: print(f"거래번호 {transaction_id}를 찾을 수 없습니다.") except Exception as e: print(f"오류 발생: {e}") finally: db_manager.close_all() def check_sale_main_data(transaction_id): """특정 거래의 SALE_MAIN 데이터 확인""" db_manager = DatabaseManager() try: session = db_manager.get_session('PM_PRES') query = text(""" SELECT * FROM SALE_MAIN WHERE SL_NO_order = :transaction_id """) result = session.execute(query, {'transaction_id': transaction_id}).fetchone() if result: print("\n" + "=" * 80) print(f"거래번호 {transaction_id}의 SALE_MAIN 데이터") print("=" * 80) for key in result._mapping.keys(): value = result._mapping[key] print(f"{key:30} = {value}") print("=" * 80) else: print(f"거래번호 {transaction_id}를 찾을 수 없습니다.") except Exception as e: print(f"오류 발생: {e}") finally: db_manager.close_all() if __name__ == '__main__': # 스크린샷의 거래번호 check_sale_sub_data('20260123000261') check_sale_main_data('20260123000261')