39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
import sys
|
|
import os
|
|
import datetime
|
|
|
|
sys.path.insert(0, "/home/hoon/kis_bot")
|
|
from database import TradeDB
|
|
|
|
def main():
|
|
db = TradeDB()
|
|
try:
|
|
tables = ["ws_orderbook", "kis_ws_orderbook", "ls_ws_orderbook"]
|
|
|
|
for table in tables:
|
|
print(f"\n--- {table} ---")
|
|
try:
|
|
# 1. Show columns
|
|
cols = db.conn.execute(f"SHOW COLUMNS FROM {table}").fetchall()
|
|
print("Columns:", [dict(c)["Field"] for c in cols])
|
|
|
|
# 2. Get 1 sample row to see data types
|
|
sample = db.conn.execute(f"SELECT * FROM {table} ORDER BY id DESC LIMIT 1").fetchone()
|
|
if sample:
|
|
print("Sample row:")
|
|
for k, v in dict(sample).items():
|
|
print(f" {k}: {v} (type: {type(v)})")
|
|
else:
|
|
print("Table is completely empty.")
|
|
|
|
# 3. Total count in table
|
|
total = db.conn.execute(f"SELECT COUNT(*) as c FROM {table}").fetchone()
|
|
print("Total rows:", dict(total)["c"])
|
|
except Exception as e:
|
|
print(f"Error checking {table}: {e}")
|
|
finally:
|
|
db.close()
|
|
|
|
if __name__ == "__main__":
|
|
main()
|