Files
kis_bot/scratch/check_db_schema.py

41 lines
1.2 KiB
Python

import sys
from pathlib import Path
sys.path.append(str(Path(__file__).resolve().parent.parent))
from database import TradeDB
db = TradeDB()
print("--- ws_ticks Schema ---")
cols = db.conn.execute("SHOW COLUMNS FROM ws_ticks").fetchall()
for r in cols:
print(dict(r))
print("\n--- ws_ticks Sample ---")
sample = db.conn.execute("SELECT * FROM ws_ticks ORDER BY id DESC LIMIT 5").fetchall()
for r in sample:
print(dict(r))
print("\n--- ls_ws_ticks Sample ---")
sample = db.conn.execute("SELECT * FROM ls_ws_ticks ORDER BY id DESC LIMIT 5").fetchall()
for r in sample:
print(dict(r))
print("\n--- ws_candles Sample ---")
sample = db.conn.execute("SELECT * FROM ws_candles ORDER BY id DESC LIMIT 5").fetchall()
for r in sample:
print(dict(r))
print("\n--- ws_orderbook Schema & Sample ---")
cols = db.conn.execute("SHOW COLUMNS FROM ws_orderbook").fetchall()
print([dict(r)['Field'] for r in cols])
sample = db.conn.execute("SELECT * FROM ws_orderbook ORDER BY id DESC LIMIT 5").fetchall()
for r in sample:
print(dict(r))
print("\n--- ls_ws_orderbook Sample ---")
sample = db.conn.execute("SELECT * FROM ls_ws_orderbook ORDER BY id DESC LIMIT 5").fetchall()
for r in sample:
print(dict(r))
db.close()