import sqlite3 import os db_path = 'data/futures_analysis.db' print(f'数据库文件路径: {os.path.abspath(db_path)}') print(f'数据库存在: {os.path.exists(db_path)}') if os.path.exists(db_path): print(f'数据库大小: {os.path.getsize(db_path)} 字节') conn = sqlite3.connect(db_path) cursor = conn.execute("SELECT name FROM sqlite_master WHERE type='table'") tables = [row[0] for row in cursor.fetchall()] print(f'数据库表列表: {tables}') if 'ai_analysis_cache' in tables: cursor = conn.execute("SELECT COUNT(*) FROM ai_analysis_cache") count = cursor.fetchone()[0] print(f'AI分析记录数: {count}') cursor = conn.execute("SELECT id, symbol, created_at FROM ai_analysis_cache ORDER BY created_at DESC LIMIT 5") records = cursor.fetchall() print(f'最近5条记录:') for r in records: print(f' ID: {r[0]}, 合约: {r[1]}, 时间: {r[2]}') else: print('❌ ai_analysis_cache 表不存在!') conn.close() else: print('❌ 数据库文件不存在!')