import sys sys.path.insert(0, '.') from database import TradeDB db = TradeDB() try: # ws_ticks 컬럼 확인 완료 - tick_time 기반으로 오늘 조회 # tick_time 형식 확인 sample = db.conn.execute( "SELECT tick_time, source FROM ws_ticks WHERE market='KR' ORDER BY id DESC LIMIT 5" ).fetchall() print("샘플:", [dict(r) for r in sample]) # 오늘 20260808 시간대별 건수 - tick_time으로 필터 rows = db.conn.execute( """ SELECT SUBSTR(tick_time, 1, 11) as hhmm10, source, COUNT(*) as cnt FROM ws_ticks WHERE market='KR' AND tick_time LIKE %s GROUP BY SUBSTR(tick_time, 1, 11), source ORDER BY hhmm10 ASC LIMIT 100 """, ('20260808%',) ).fetchall() print(f"\n[20260808] 시간대별 틱 적재 현황 (10분 단위):") for r in rows: print(f" {dict(r)['hhmm10']} | {dict(r).get('source','?'):6s} | {dict(r)['cnt']:,}건") finally: db.close()