DataBase Error #5

Closed
opened 2026-02-22 17:15:29 -05:00 by yindo · 5 comments
Owner

Originally created by @zhtwh on GitHub (Mar 7, 2025).

参数传递中,SQL Excute 接受了大模型的所有字符,导致运行失败。

应传输的text:
SELECT 商品名称, SUM(下单量) AS 总下单量 FROM pop_mc GROUP BY 商品名称 ORDER BY 总下单量 DESC LIMIT 10;
实际接受到的text:
sql SELECT 商品名称, SUM(下单量) AS 总下单量 FROM pop_mc GROUP BY 商品名称 ORDER BY 总下单量 DESC LIMIT 10;

报错信息如下:
Error: (pymysql.err.ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sql\nselect 商品名称, sum(下单量) as 总下单量\nfrom pop_mc\ngroup by ' at line 1") [SQL: sql
select 商品名称, sum(下单量) as 总下单量
from pop_mc
group by 商品名称
order by 总下单量 desc
limit 10;

(Background on this error at: https://sqlalche.me/e/20/f405)

Originally created by @zhtwh on GitHub (Mar 7, 2025). 参数传递中,SQL Excute 接受了大模型的所有字符,导致运行失败。 应传输的text: SELECT 商品名称, SUM(下单量) AS 总下单量 FROM pop_mc GROUP BY 商品名称 ORDER BY 总下单量 DESC LIMIT 10; 实际接受到的text: ```sql SELECT 商品名称, SUM(下单量) AS 总下单量 FROM pop_mc GROUP BY 商品名称 ORDER BY 总下单量 DESC LIMIT 10; ``` 报错信息如下: Error: (pymysql.err.ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sql\nselect 商品名称, sum(下单量) as 总下单量\nfrom pop_mc\ngroup by ' at line 1") [SQL: sql select 商品名称, sum(下单量) as 总下单量 from pop_mc group by 商品名称 order by 总下单量 desc limit 10; (Background on this error at: https://sqlalche.me/e/20/f405)
yindo closed this issue 2026-02-22 17:15:29 -05:00
Author
Owner

@alterxyz commented on GitHub (Mar 10, 2025):

@hjlarry

@alterxyz commented on GitHub (Mar 10, 2025): @hjlarry
Author
Owner

@hjlarry commented on GitHub (Mar 10, 2025):

Try using the correct prompt, such as "only provide executable SQL queries," or consider switching to a different LLM.

@hjlarry commented on GitHub (Mar 10, 2025): Try using the correct prompt, such as "only provide executable SQL queries," or consider switching to a different LLM.
Author
Owner

@zhtwh commented on GitHub (Mar 10, 2025):

Try using the correct prompt, such as "only provide executable SQL queries," or consider switching to a different LLM.
LLM has correctly generated the SQL. When it is passed to SQL Execute, the string ""SQL"" is added additionally.

@zhtwh commented on GitHub (Mar 10, 2025): > Try using the correct prompt, such as "only provide executable SQL queries," or consider switching to a different LLM. LLM has correctly generated the SQL. When it is passed to SQL Execute, the string ""SQL"" is added additionally.
Author
Owner

@hjlarry commented on GitHub (Mar 10, 2025):

Image

I'm unable to replicate it.

@hjlarry commented on GitHub (Mar 10, 2025): ![Image](https://github.com/user-attachments/assets/9a5d7637-f911-4dea-8f4d-6ad82d3f3f1f) I'm unable to replicate it.
Author
Owner

@zhtwh commented on GitHub (Mar 10, 2025):

Image

I'm unable to replicate it.
{
"text": "sql\nSELECT 商品名称, 下单量\nFROM pop_mc\nORDER BY 下单量 DESC\nLIMIT 10;\n",

Something different ,text output

@zhtwh commented on GitHub (Mar 10, 2025): > ![Image](https://github.com/user-attachments/assets/9a5d7637-f911-4dea-8f4d-6ad82d3f3f1f) > > I'm unable to replicate it. { "text": "```sql\nSELECT 商品名称, 下单量\nFROM pop_mc\nORDER BY 下单量 DESC\nLIMIT 10;\n```", Something different ,text output
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-plugins#5