check_db.py 1.0 KB

12345678910111213141516171819202122232425262728
  1. import sqlite3
  2. from datetime import datetime
  3. conn = sqlite3.connect('data/trading_data_20251103.db')
  4. cursor = conn.cursor()
  5. print('=== Price Data (最新10条) ===')
  6. cursor.execute('SELECT * FROM price_data ORDER BY timestamp DESC LIMIT 10')
  7. rows = cursor.fetchall()
  8. for row in rows:
  9. ts = datetime.fromtimestamp(row[1]).strftime('%Y-%m-%d %H:%M:%S')
  10. print(f"时间: {ts}, 标的: {row[3]}, Binance: {row[5]}, Lighter: {row[4]}, 价差: {row[6]} bps")
  11. print('\n=== Trading Events (最新10条) ===')
  12. cursor.execute('SELECT * FROM trading_events ORDER BY timestamp DESC LIMIT 10')
  13. rows = cursor.fetchall()
  14. for row in rows:
  15. ts = datetime.fromtimestamp(row[1]).strftime('%Y-%m-%d %H:%M:%S')
  16. print(f"时间: {ts}, 标的: {row[3]}, 事件: {row[4]}, 价格: {row[5]}, 状态: {row[8]}")
  17. print('\n=== 数据统计 ===')
  18. cursor.execute('SELECT COUNT(*) FROM price_data')
  19. print(f"价格数据总数: {cursor.fetchone()[0]}")
  20. cursor.execute('SELECT COUNT(*) FROM trading_events')
  21. print(f"交易事件总数: {cursor.fetchone()[0]}")
  22. conn.close()