I am developing a Webapp using Flask. At some point, I have to insert a certain HTML script into a MySQL database:
<h3>Welcome!</h3>
<p>Some text</p>
When I insert it into the database (when it is returned by flask's 'render_template' function):
\n\n<h3>Welcome!</h3>\n\n\n\n<p>Some text</p>
I get the following error:
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
I first don't understand what 'JSON serializable' means, and I want to know what I am doing wrong. I have already tried taking off the linebreaks (\n
) but it still shows the same error. Why? I am thankful for any answer you can provide.