解决Flask使用pymysql驱动的Warning: (1366, "Incorrect string value: '\\xD6\\xD0\\xB9\\xFA\\xB1\\xEA...'
Flask项目字符警告——1366
警告提示:site-packages\pymysql\cursors.py:170: Warning: (1366, "Incorrect string value: '\\xD6\\xD0\\xB9\\xFA\\xB1\\xEA...' for column 'VARIABLE_VALUE' at row 485")
result = self._query(query)
解决方法:
Flask项目中使用mysql数据库启动项目是发出警告:
Warning: (1366, “Incorrect string value: ‘\xD6\xD0\xB9\xFA\xB1\xEA…’ for column ‘VARIABLE_VALUE’ at row 479”)
第一步:安装mysql的驱动
pip install mysql-connector -i https://pypi.tuna.tsinghua.edu.cn/simple
第二步:修改config中修改代码
SQLALCHEMY_DATABASE_URI='mysql://root:password@localhost/database'
改为:
SQLALCHEMY_DATABASE_URI='mysql+mysqlconnector://root:password@localhost/database'