环境:Python 3.5+, Django 1.9+

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

1. 两个库的作者是同一个人INADA Naoki, pip库邮箱都指向mailto:songofacandy@gmail.com

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!

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐