Files
codex_jxs_code/check_db.py
2026-02-28 13:21:58 +08:00

37 lines
1.2 KiB
Python

import sqlite3
from pathlib import Path
from datetime import datetime
db_path = Path("/Users/ddrwode/code/codex_jxs_code/models/database.db")
conn = sqlite3.connect(str(db_path))
cursor = conn.cursor()
# 列出所有表
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
tables = cursor.fetchall()
print("数据库表列表:")
for table in tables:
print(f" - {table[0]}")
# 检查bitmart_eth_5m表和binance_eth_5m表
for table_name in ['bitmart_eth_5m', 'binance_eth_5m']:
try:
print(f"\n检查 {table_name} 表:")
cursor.execute(f"SELECT COUNT(*) FROM {table_name}")
count = cursor.fetchone()[0]
print(f" 记录数: {count}")
if count > 0:
# 获取时间范围
cursor.execute(f"SELECT MIN(id), MAX(id) FROM {table_name}")
result = cursor.fetchone()
if result[0] and result[1]:
min_id, max_id = result
min_date = datetime.fromtimestamp(min_id/1000).strftime('%Y-%m-%d %H:%M:%S')
max_date = datetime.fromtimestamp(max_id/1000).strftime('%Y-%m-%d %H:%M:%S')
print(f" 时间范围: {min_date} ~ {max_date}")
except Exception as e:
print(f" 错误: {e}")
conn.close()