如何在Windows上的Python 3中连接到MySQL? [英] How can I connect to MySQL in Python 3 on Windows?
问题描述
我在Windows上使用ActiveState Python 3,并想连接到我的MySQL数据库.
我听说 mysqldb
是要使用的模块.
我找不到用于Python 3的mysqldb
.
在mysqldb
的二进制文件存在的地方有可用的存储库吗?
如何在Windows上的Python 3中连接到MySQL?
当前有一些将python 3与mysql结合使用的选项:
https://pypi.python.org/pypi/mysql-connector-python >
- Oracle的官方支持
- 纯python
- 有点慢
- 与MySQLdb不兼容
https://pypi.python.org/pypi/pymysql
- 纯python
- 比mysql-connector快
- 在调用
pymysql.install_as_MySQLdb()
后几乎与
MySQLdb
完全兼容
https://pypi.python.org/pypi/cymysql
- 具有可选C加速功能的pymysql叉
https://pypi.python.org/pypi/mysqlclient
- Django推荐的库.
- 原始MySQLdb的友好分支,希望有朝一日能重新合并
- 最快的实现,因为它基于C.
- 与MySQLdb最兼容,因为它是一个分叉
- Debian和Ubuntu使用它来提供
python-mysqldb
和python3-mysqldb
软件包.
这里的基准: https://github.com/methane/mysql-driver-benchmarks
I am using ActiveState Python 3 on Windows and wanted to connect to my MySQL database.
I heard that mysqldb
was the module to use.
I can't find mysqldb
for Python 3.
Is there a repository available where the binaries exist for mysqldb
?
How can I connect to MySQL in Python 3 on Windows?
There are currently a few options for using Python 3 with mysql:
https://pypi.python.org/pypi/mysql-connector-python
- Officially supported by Oracle
- Pure python
- A little slow
- Not compatible with MySQLdb
https://pypi.python.org/pypi/pymysql
- Pure python
- Faster than mysql-connector
- Almost completely compatible with
MySQLdb
, after callingpymysql.install_as_MySQLdb()
https://pypi.python.org/pypi/cymysql
- fork of pymysql with optional C speedups
https://pypi.python.org/pypi/mysqlclient
- Django's recommended library.
- Friendly fork of the original MySQLdb, hopes to merge back some day
- The fastest implementation, as it is C based.
- The most compatible with MySQLdb, as it is a fork
- Debian and Ubuntu use it to provide both
python-mysqldb
andpython3-mysqldb
packages.
benchmarks here: https://github.com/methane/mysql-driver-benchmarks
这篇关于如何在Windows上的Python 3中连接到MySQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!