35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
import sys, os, datetime
|
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
|
|
from database import TradeDB
|
|
|
|
db = TradeDB()
|
|
try:
|
|
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
# env_config_ext 컬럼 확인
|
|
cols = [dict(r)["Field"] for r in db.conn.execute("SHOW COLUMNS FROM env_config_ext").fetchall()]
|
|
print("[env_config_ext 컬럼]:", cols)
|
|
|
|
# 현재 값 확인
|
|
current = db.conn.execute(
|
|
"SELECT * FROM env_config_ext WHERE env_key = 'WS_ORDERBOOK_SAVE_KIS'"
|
|
).fetchone()
|
|
print("현재 WS_ORDERBOOK_SAVE_KIS:", dict(current) if current else "없음")
|
|
|
|
# UPSERT
|
|
db.conn.execute(
|
|
"INSERT INTO env_config_ext (env_key, env_value, updated_at) "
|
|
"VALUES (%s, %s, %s) "
|
|
"ON DUPLICATE KEY UPDATE env_value=VALUES(env_value), updated_at=VALUES(updated_at)",
|
|
("WS_ORDERBOOK_SAVE_KIS", "true", now),
|
|
)
|
|
db.conn.commit()
|
|
|
|
# 재조회 검증
|
|
after = db.conn.execute(
|
|
"SELECT * FROM env_config_ext WHERE env_key = 'WS_ORDERBOOK_SAVE_KIS'"
|
|
).fetchone()
|
|
print("패치 후 값:", dict(after))
|
|
finally:
|
|
db.close()
|