Python interface to MySQL
Actively maintained. Last release 12 days ago, commits in 10 of the last 26 weeks. A safe choice.
pip install mysqlclientmysqlclient
This project is a fork of MySQLdb1. This project adds Python 3 support and fixed many bugs.
Support
Do Not use Github Issue Tracker to ask help. OSS Maintainer is not free tech support
When your question looks relating to Python rather than MySQL/MariaDB:
- Python mailing list python-list
- Slack pythondev.slack.com
Or when you have question about MySQL/MariaDB:
Free threading Python
[!NOTE] The support for Free threading Python is experimental.
Since v2.2.8, free threading is supported when importing the extension module. Therefore, importing MySQLdb does not acquire GIL.
However, this library does not support simultaneous operations on a single Connection object from multiple threads, regardless of free threading, and the behavior in such cases remains undefined.
[!WARNING] Do not use a single Connection object from multiple threads simultaneously.
Install
Windows
Building mysqlclient on Windows is very hard. But there are some binary wheels you can install easily.
If binary wheels do not exist for your version of Python, it may be possible to
build from source, but if this does not work, do not come asking for support.
To build from source, download the
MariaDB C Connector and install
it. It must be installed in the default location
(usually "C:\Program Files\MariaDB\MariaDB Connector C" or
"C:\Program Files (x86)\MariaDB\MariaDB Connector C" for 32-bit). If you
build the connector yourself or install it in a different location, set the
environment variable MYSQLCLIENT_CONNECTOR before installing. Once you have
the connector installed and an appropriate version of Visual Studio for your
version of Python: