Files
kis_trader/scratch/patch_env_kis_ob.py

24 lines
870 B
Python

import sys, os
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
from database import TradeDB
db = TradeDB()
try:
# env_config는 컬럼=키 구조임을 확인 → UPDATE 방식으로 패치
cols = [dict(r)["Field"] for r in db.conn.execute("SHOW COLUMNS FROM env_config").fetchall()]
print("WS_ORDERBOOK_SAVE_KIS 컬럼 있음?" , 'WS_ORDERBOOK_SAVE_KIS' in cols)
# 현재 값
current = db.conn.execute("SELECT WS_ORDERBOOK_SAVE_KIS FROM env_config").fetchone()
print("현재 값:", dict(current) if current else "row 없음")
# 패치 적용
db.conn.execute("UPDATE env_config SET WS_ORDERBOOK_SAVE_KIS = 'true'")
db.conn.commit()
# 검증
after = db.conn.execute("SELECT WS_ORDERBOOK_SAVE_KIS FROM env_config").fetchone()
print("패치 후 값:", dict(after))
finally:
db.close()