python往mysql(5.7)插入数据报错:
Incorrect string value: \\'\\xF0\\x9F\\x86\\x9455...\\' for column \\'description\\' at row 1'
self.__connection = pymysql.connect(
host=self.__db_host,
port=self.__db_port,
user=self.__db_user,
passwd=self.__db_psw,
db=self.__db_database,
charset='utf8'
)
插入字符串包含字符( ),中间带边框的ID。(这个字符复制到该文档中会导致文档从该字符不显示^_^,写了两次才发现这个坑)
1.参考https://blog.csdn.net/lemonmagister/article/details/77969440。插入仍报错
3.修改数据库连接charset='utf8mb4',插入成功
4.还原步骤1,使用数据库连接charset='utf8mb4',插入成功