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.
32 lines
906 B
32 lines
906 B
|
1 week ago
|
"""
|
||
|
|
更新AI分析缓存表结构
|
||
|
|
添加 kline_timestamp 字段
|
||
|
|
"""
|
||
|
|
import sqlite3
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
project_root = Path(__file__).parent
|
||
|
|
ANALYSIS_DB_PATH = project_root / "data" / "futures_analysis.db"
|
||
|
|
|
||
|
|
def add_kline_timestamp_column():
|
||
|
|
"""添加 kline_timestamp 列"""
|
||
|
|
conn = sqlite3.connect(str(ANALYSIS_DB_PATH))
|
||
|
|
cursor = conn.cursor()
|
||
|
|
|
||
|
|
# 检查列是否已存在
|
||
|
|
cursor.execute("PRAGMA table_info(ai_analysis_cache)")
|
||
|
|
columns = [col[1] for col in cursor.fetchall()]
|
||
|
|
|
||
|
|
if 'kline_timestamp' in columns:
|
||
|
|
print("✅ kline_timestamp 列已存在")
|
||
|
|
else:
|
||
|
|
print("添加 kline_timestamp 列...")
|
||
|
|
cursor.execute("ALTER TABLE ai_analysis_cache ADD COLUMN kline_timestamp DATETIME")
|
||
|
|
conn.commit()
|
||
|
|
print("✅ kline_timestamp 列添加成功")
|
||
|
|
|
||
|
|
conn.close()
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
add_kline_timestamp_column()
|