pymysql直接插入带有双引号或单引号的字符串,报错:
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 '
解决方法:
使用pymysql.escape_string(str) 转义: escape_string(record["content"])
# v1.0.0及以上 from pymysql.converters import escape_string # v0.10.1及以下 from pymysql import escape_string
#data为含有单引号或者双引号的字符串 data = escape_string(data)