mysqlclient和PyMySQL對比


環境:Python 3.5+, Django 1.9+

最初用django時,搜索時發現PyMySQL的文章很多,然而在django的官方文檔中python3版的mysql客戶端驅動確沒有提到PyMySQL,只提到了mysqlclient,再細看下去發現:

1. 兩個庫的作者是同一個人INADA Naoki, pip庫郵箱都指向mailto:songofacandy@gmail.com

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!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM