You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
buffer_platform/check_db.py

56 lines
1.6 KiB

import sqlite3
import os
from pathlib import Path
db_path = Path(__file__).parent / "data" / "futures_analysis.db"
print("=" * 60)
print("数据库信息检查")
print("=" * 60)
print(f"数据库路径: {db_path}")
print(f"文件存在: {db_path.exists()}")
if db_path.exists():
print(f"文件大小: {db_path.stat().st_size} bytes")
print(f"最后修改: {db_path.stat().st_mtime}")
conn = sqlite3.connect(str(db_path))
cursor = conn.cursor()
# 获取所有表
cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
tables = cursor.fetchall()
print(f"\n数据库表 ({len(tables)}):")
for table in tables:
table_name = table[0]
cursor.execute(f"SELECT COUNT(*) FROM {table_name}")
count = cursor.fetchone()[0]
print(f" - {table_name}: {count} 条记录")
# 检查AI模型配置
print("\n" + "=" * 60)
print("AI模型配置检查")
print("=" * 60)
try:
cursor.execute("SELECT id, provider, model_name, is_active, enabled FROM ai_model_configs")
models = cursor.fetchall()
print(f"AI模型数量: {len(models)}")
if models:
for m in models:
print(f" ID: {m[0]}")
print(f" Provider: {m[1]}")
print(f" Model Name: {m[2]}")
print(f" Active: {m[3]}")
print(f" Enabled: {m[4]}")
print()
else:
print(" 没有配置AI模型!")
except sqlite3.OperationalError as e:
print(f" 查询失败: {e}")
conn.close()
else:
print("数据库文件不存在!")
print("=" * 60)