If there are any questions, errors or suggestions comment them down below so that I could check them out too. Alternatively, to run the installer from the command line, use this command in a console window, where VER and PYVER are the respective Connector/Python and Python version numbers in the installer file name: > msiexec /i mysql-connector-python-VER-pyPYVER.msiSubsequent executions of Connector/Python using the MSI installer permit you to either repair or remove the existing Connector/Python.
INSTALL MYSQL IN PYTHON INSTALL
I hope this helped you install MySQLdb for Python on your Windows computer easier. If MySQLdb is not yet installed then it will raise a ModuleNotFoundError like the screenshot below. If all is well, then when you run the code above it would print Succesfully Connected to database using MySQLdb! You can change the following parameters to check if it can connect to your MySQL database or MariaDB database. Print("Succesfully Connected to database using MySQLdb!") Print("Connecting to database using MySQLdb")ĭb_connection = nnect(host='DB_HOST', Testing MySQLdb Installationīelow is the code I use if my MySQLdb connector has been properly installed in Windows. Once pip says that you have Successfully installed mysqlclient you are good to go on using MySQLdb as your MySQL connector for Python. Note: The file on the command will be different if you use a different Python version or if there is an update on the version of the mysqlclient (MySQLdb). In my case the command is pip install mysqlclient-1.3.13-cp36-cp36m-win_amd64.whl I am currently using Python 3.6.8, so I downloaded mysqlclient‑1.3.13‑cp36‑cp36m‑win_amd64.whl. whl file was compiled if you hover the mouse over it.ĭownload the appropriate. To install MySQLdb on Windows go to this link – Screenshot of list of precompiled MySQLdb connectors for Python. So how do we install MySQLdb for Python on Windows? You can follow the steps below. You can still run the command above but it will look for Microsoft Visual C++ Build Tools, which if you install it in your Windows machine for the purpose of only using MySQLdb will become a program that occupies space but you will never ever use again. Unfortunately, the pypi documentation is already out of date with the latest release was on Jan 3, 2014. You can actually install MySQLdb using pip. Problems with installing MySQLdb on Windows If you are interested why I prefer MySQLdb compared to other MySQL connectors you may want to read the comparison of MySQL-connector and MySQLdb from Charles Nagy. Problems with installing MySQLdb on Windows.
INSTALL MYSQL IN PYTHON HOW TO
Especially me, since each time I am doing a Python project that needs to connect to MariaDB or MySQL I always look on how to install MySQLdb. I am creating this article for those who want to install MySQLdb for Python 3 for Windows. My favorite Python connector for MySQL or MariaDB is MySQLdb, the problem with this connector is that it is complicated to install on Windows!