浏览代码

feat: 添加数据库检查脚本并更新.gitignore

添加check_db.py脚本用于检查数据库内容和统计信息
更新.gitignore以忽略数据库日志文件
skyfffire 4 天之前
父节点
当前提交
46500b747a
共有 2 个文件被更改,包括 29 次插入0 次删除
  1. 1 0
      .gitignore
  2. 28 0
      check_db.py

+ 1 - 0
.gitignore

@@ -114,3 +114,4 @@ config.toml
 
 
 # db
 # db
 *.db
 *.db
+*.db-journal

+ 28 - 0
check_db.py

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