mysqlclient和PyMySQL对比

Posted roystime

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysqlclient和PyMySQL对比相关的知识,希望对你有一定的参考价值。

环境:Python 3.5+, Django 1.9+

最初用django时,搜索时发现Pymysql的文章很多,然而在django的官方文档中python3版的mysql客户端驱动确没有提到PyMySQL,只提到了mysqlclient,再细看下去发现:

1. 两个库的作者是同一个人INADA Naoki, pip库邮箱都指向mailto:[email protected]

2. PyMySQL的代码人员methane说mysqlclient速度更快及PyMySQL的应用场景,参见:https://github.com/PyMySQL/PyMySQL/issues/342 

 mysqlclient-python is much faster than PyMySQL.
When to use PyMySQL is:

    • You can‘t use libmysqlclient for some reason
    • You want to use monkeypatched socket of gevent or eventlet
    • You wan‘t to hack mysql protocol

3. Django1.9.12官方文档中:

Django requires mysqlclient 1.3.3 or later. Note that Python 3.2 is not supported. Except for the Python 3.3+ support,
mysqlclient should mostly behave the same as MySQLDB.

4. https://python.libhunt.com/project/mysqlclient-python/vs/pymysql  两者基本面的对比

 

经上对比,准备先用mysqlclient!

 



以上是关于mysqlclient和PyMySQL对比的主要内容,如果未能解决你的问题,请参考以下文章

Python3 mysqlclient-1.3.6(又名 PyMySQL)的用法?

python3.8 + django3.0.7 使用pymysql报错:django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13

mysql客户端pymysql在python下性能比较

Django2.X 与 PyMySQL包兼容

Django - installing mysqlclient error: mysqlclient 1.3.13 or newer is required; you have 0.9.3

Django踩坑之django.core.exceptions.ImproperlyConfigured mysqlclient 1.3.13 or newer is required; you ha