我正在开发一个Web应用程序使用Flask。在某些时候,我必须插入某些HTML脚本到MySQL数据库:插入HTML到MySQL数据库显示类型错误
<h3>Welcome!</h3>
<p>Some text</p>
当我将其插入到数据库中(当它被瓶中的“render_template”函数返回):
\n\n<h3>Welcome!</h3>\n\n\n\n<p>Some text</p>
我得到以下错误:
TypeError: ProgrammingError(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '\\\\\\\\n\\\\n<h3>Welcome!</h3>\\\\n\\\\n\\\\n\\\\n<p>Some text' at line 1") is not JSON serializable
我第一次不明白什么JSON序列化“的意思,我想知道我做错了。我已经尝试脱线(\n
),但它仍然显示相同的错误。为什么?我很感谢你能提供的任何答案。
where is SQL query? – furas