服务器上跑python(flask框架)报的错
[SQL: INSERT INTO question (title, content, create_time, author_id) VALUES (%(title)s, %(content)s, %(create_time)s, %(author_id)s)]
[parameters: {'title': 'docker 部署mysql', 'content': ',g,gu', 'create_time': datetime.datetime(2022, 12, 9, 15, 52, 38, 18052), 'author_id': 1}]
(Background on this error at: https://sqlalche.me/e/14/9h9h)
pymysql.err.DataError: (1366, "Incorrect string value: '\\xE9\\x83\\xA8\\xE7\\xBD\\xB2...' for column 'title' at row 1")
问了必应大致给出的是编码问题,要改成utf8,
项目里数据库的配置:
数据库(用的是云数据库)的编码:
然后试了在项目里提交英文,是不报错的,post 中文就 post 不上去(所以应该是编码问题)
然后就不知道往哪里改了,感觉编码都是 utf8了 😭