优化连接不上时创建表

This commit is contained in:
z66
2025-11-05 09:50:55 +08:00
parent 4154eb452f
commit b0bf0fa9bc
4 changed files with 191 additions and 23 deletions
@@ -195,7 +195,7 @@ class RSSDataAIProcessor:
raise
def create_ai_result_table(self):
"""创建AI处理结果表"""
"""创建AI处理结果表(使用安全方法,确保不会删除现有数据)"""
create_sql = f"""
CREATE TABLE IF NOT EXISTS {self.ai_table} (
id INT AUTO_INCREMENT PRIMARY KEY COMMENT '主键ID',
@@ -221,10 +221,13 @@ class RSSDataAIProcessor:
"""
try:
self.db_agent.execute_sql(create_sql)
self.log.info(f"成功创建AI结果表: {self.ai_table}")
# 使用安全方法创建表(如果不存在),确保不会删除现有数据
self.db_agent.create_table_if_not_exists(
table_name=self.ai_table,
create_sql=create_sql
)
except Exception as e:
self.log.error(f"创建AI结果表失败: {str(e)}", exc_info=True)
self.log.error(f"创建AI结果表失败(可能是数据库连接问题): {str(e)}", exc_info=True)
raise
def load_unprocessed_data(self, limit: int = 100) -> pd.DataFrame: