zoukankan      html  css  js  c++  java
  • mac + python3.8 + django3.0.8 + mysql 遇到数据库连接包问题

    到达数据库迁移的时候, 出现了错误

    django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
    Did you install mysqlclient?

    安装pymysql包

    pip install pymysql

    然后在与想settings.py 同一文件夹的_init_.py中增加

    import pymysql
    
    pymysql.install_as_MySQLdb()

    增加完成了之后又出现了错误

    File "/Users/mac/.virtualenvs/django-sPhxDNwQ/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 36, in <module>
        raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
    django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
        

    方案是去Django的包中改代码

    路径是:

    /Users/mac/.virtualenvs/django-sPhxDNwQ/lib/python3.7/site-packages/django/db/backends/mysql/base.py

    我的是虚拟环境,个人找自己mysql的安装包文件base.py

    把这行

    if version < (1, 3, 13):
       raise ImproperlyConfigured(
           'mysqlclient 1.3.13 or newer is required; you have %s.'
           % Database.__version__
       )
       

    改成这样, 全部注释:

    #if version < (1, 3, 13):
      # raise ImproperlyConfigured(
       #    'mysqlclient 1.3.13 or newer is required; you have %s.'
       #    % Database.__version__
       #)

    然后在改另一个文件

    路径是: /Users/mac/.virtualenvs/django-sPhxDNwQ/lib/python3.7/site-packages/django/db/backends/mysql/operations.py

    把这行

    query = query.decode(errors='replace')

    改成

    query = query.encode(errors='replace')
     
  • 相关阅读:
    招聘.NET开发人员
    SQL 2005 SSIS 导入数据效率问题
    用户控件使用事件与调用页面交互
    使用sql语句删除标识列属性
    poj1520
    poj1476
    poj1363
    poj1477
    poj1312
    大端法小端法与union
  • 原文地址:https://www.cnblogs.com/shenZS/p/13334902.html
Copyright © 2011-2022 走看看