|
|
@@ -1,19 +1,52 @@
|
|
|
import sqlite3
|
|
|
from datetime import datetime
|
|
|
+import os
|
|
|
|
|
|
-conn = sqlite3.connect('data/trading_data_20251103.db')
|
|
|
+# 找到最新的数据库文件
|
|
|
+data_dir = 'data'
|
|
|
+db_files = [f for f in os.listdir(data_dir) if f.startswith('trading_data_') and f.endswith('.db')]
|
|
|
+db_files.sort(reverse=True)
|
|
|
+
|
|
|
+if not db_files:
|
|
|
+ print("没有找到数据库文件")
|
|
|
+ exit(1)
|
|
|
+
|
|
|
+db_path = os.path.join(data_dir, db_files[0])
|
|
|
+print(f"使用数据库: {db_path}")
|
|
|
+
|
|
|
+conn = sqlite3.connect(db_path)
|
|
|
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"所有列: {row}")
|
|
|
- print(f" 时间: {ts}")
|
|
|
- print(f" ID: {row[0]}, 时间戳: {row[1]}, 会话ID: {row[2]}, 标的: {row[3]}")
|
|
|
- print(f" Lighter价格: {row[4]}, Binance价格: {row[5]}, 价差(bps): {row[6]}")
|
|
|
- print()
|
|
|
+# 先查看所有表
|
|
|
+print('\n=== 数据库中的表 ===')
|
|
|
+cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
|
|
|
+tables = cursor.fetchall()
|
|
|
+for table in tables:
|
|
|
+ print(f" - {table[0]}")
|
|
|
+
|
|
|
+# 查看price_data表的结构
|
|
|
+print('\n=== price_data 表结构 ===')
|
|
|
+try:
|
|
|
+ cursor.execute("PRAGMA table_info(price_data)")
|
|
|
+ columns = cursor.fetchall()
|
|
|
+ for col in columns:
|
|
|
+ print(f" {col[1]}: {col[2]}")
|
|
|
+except Exception as e:
|
|
|
+ print(f" 错误: {e}")
|
|
|
+
|
|
|
+print('\n=== Price Data (最新10条) ===')
|
|
|
+try:
|
|
|
+ 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"所有列: {row}")
|
|
|
+ print(f" 时间: {ts}")
|
|
|
+ print(f" ID: {row[0]}, 时间戳: {row[1]}, 会话ID: {row[2]}, 标的: {row[3]}")
|
|
|
+ print(f" Lighter价格: {row[4]}, Binance价格: {row[5]}, 价差(bps): {row[6]}")
|
|
|
+ print()
|
|
|
+except Exception as e:
|
|
|
+ print(f" 错误: {e}")
|
|
|
|
|
|
print('\n=== Trading Events (最新10条) ===')
|
|
|
cursor.execute('SELECT * FROM trading_events ORDER BY timestamp DESC LIMIT 10')
|