Django2.2 pymysql 连接mysql数据库的坑

参考链接 https://www.52pojie.cn/thread-921141-1-1.html

1. mysqlclient 1.3版本不对

解决办法:注释掉D:\Users\xxx\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\db\backends\mysql\base.py 的35和36这两行即可

2. 字符集的问题:报错如下:File "C:\Users\Administrator\PycharmProjects\xxx\venv\lib\site-packages\django\db\backends\mysql\operations.py", line 146, in last_executed_query    query = query.decode(errors='replace')AttributeError: 'str' object has no attribute 'decode'

解决办法: 注释掉D:\Users\xxx\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\db\backends\mysql\operations.py 的145 和146这两行即可

这两个错误在将数据库从sqlite3迁移到mysql时报出.
posted @ 2019-08-27 19:13  ryan255  阅读(635)  评论(0编辑  收藏  举报