Problem


You want to connect to MySQL using Python.

https://stackoverflow.com/questions/25865270/how-to-install-python-mysqldb-module-using-pip




Many tutorials and post talk about using python-MySQLdb. This did not work for me, as you can see...




The error






sudo apt install python-pip





pip install MySQL-python










sudo apt-get install python-pip python-dev libmysqlclient-dev





Then try again


pip install MySQL-python


..
..the above is all nonsense..

Solution
sudo apt install python3-pip 
sudo pip3 install mysql-connector-python 






Note "mysql" is there





And to use...

Result





My dboconnect.py code:

For more info on using this module 

Acknowledgment
https://pynative.com/install-mysql-connector-python/ 

Comments