diff --git a/AI/Text2Sql/app.py b/AI/Text2Sql/app.py index 86c33c14..4bad420a 100644 --- a/AI/Text2Sql/app.py +++ b/AI/Text2Sql/app.py @@ -72,6 +72,9 @@ async def get_excel(question_id: str = Form(...), question_str: str = Form(...), if len(question_id) != 36: return {"success": False, "message": "question_id格式错误"} + # 检查此question_id 是不是已存在,存在的不能再次生成,需要全新创建一个新问题ID + if await get_question_by_id(db, question_id): + return {"success": False, "message": "question_id已存在,请重新生成"} common_prompt = ''' 返回的信息要求: 1、行政区划为NULL 或者是空字符的不参加统计 @@ -82,9 +85,10 @@ async def get_excel(question_id: str = Form(...), question_str: str = Form(...), # 获取完整 SQL sql = vn.generate_sql(question) print("生成的查询 SQL:\n", sql) - # 先删除后插入,防止重复插入 - await delete_question(db, question_id) + + # 插入数据 await insert_question(db, question_id, question) + # 检查,如果sql为空,则返回错误信息 if not sql: return {"success": False, "message": "无法生成相应的SQL语句!"} diff --git a/AI/Text2Sql/static/docx/540f67ed-2a38-43ce-bab6-b4826fa4da9c.docx b/AI/Text2Sql/static/docx/540f67ed-2a38-43ce-bab6-b4826fa4da9c.docx new file mode 100644 index 00000000..b554b326 Binary files /dev/null and b/AI/Text2Sql/static/docx/540f67ed-2a38-43ce-bab6-b4826fa4da9c.docx differ diff --git a/AI/Text2Sql/static/xlsx/97d01d91-2f58-4d4b-b417-efc9894dce36.xlsx b/AI/Text2Sql/static/xlsx/97d01d91-2f58-4d4b-b417-efc9894dce36.xlsx new file mode 100644 index 00000000..114cc49e Binary files /dev/null and b/AI/Text2Sql/static/xlsx/97d01d91-2f58-4d4b-b417-efc9894dce36.xlsx differ diff --git a/AI/Text2Sql/static/xlsx/e3f0178c-ad77-438f-81fd-9e2408cf4236.xlsx b/AI/Text2Sql/static/xlsx/e3f0178c-ad77-438f-81fd-9e2408cf4236.xlsx new file mode 100644 index 00000000..39221831 Binary files /dev/null and b/AI/Text2Sql/static/xlsx/e3f0178c-ad77-438f-81fd-9e2408cf4236.xlsx differ