django 1.5 + pymysql 错误:ImportError:无法导入名称 Thing2Literal

2023-12-25

我尝试使用 django1.5 和pymysql https://github.com/petehunt/PyMySQL/MySQLdb 如下如何使 Django 与不受支持的 MySQL 驱动程序(例如 gevent-mysql 或 Concurrence 的 MySQL 驱动程序)一起工作? https://stackoverflow.com/questions/2636536/how-to-make-django-work-with-unsupported-mysql-drivers-such-as-gevent-mysql-or-c

在我的管理命令的顶部:

+try:
+    import pymysql
+    pymysql.install_as_MySQLdb()
+except ImportError:
+    pass 

但出现错误:

/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 30, in <module>
    from MySQLdb.converters import conversions, Thing2Literal
ImportError: cannot import name Thing2Literal

如何修复它?


刚刚在 Django 1.5.1 和 PyMySQL 0.5 上遇到同样的问题

使用 CMGS 叉修复(https://github.com/CMGS/PyMySQL https://github.com/CMGS/PyMySQL)PyMySQL。希望这能进入 PyMySQL 主线。请在此处查看 CMGS 的拉取请求:https://github.com/petehunt/PyMySQL/pull/106 https://github.com/petehunt/PyMySQL/pull/106

从作者的评论和拉取请求中的反馈来看,我认为它对于生产使用来说非常可靠。

示例requirements.txt行: -e git://github.com/CMGS/PyMySQL.git#egg=PyMySQL-dev

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

django 1.5 + pymysql 错误:ImportError:无法导入名称 Thing2Literal 的相关文章

随机推荐