How can I connect to MySQL in Python 3 on Windows?(如何在 Windows 上的 Python 3 中连接到 MySQL?)
问题描述
我在 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 官方支持
- 纯蟒蛇
- 有点慢
- 与 MySQLdb 不兼容
https://pypi.python.org/pypi/pymysql
- 纯蟒蛇
- 比 mysql-connector 更快
- 几乎完全兼容
MySQLdb
,调用pymysql.install_as_MySQLdb()
https://pypi.python.org/pypi/cymysql
- pymysql 的 fork,带有可选的 C 加速
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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Windows 上的 Python 3 中连接到 MySQL?


基础教程推荐
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01