import mysql.connector
config = {
'user' : 'root',
'passwd' : ' ',
'host' : 'localhost',
'raise_on_warnings' : True,
'use_pure' : False,
}
cnx = mysql.connector.connect(**config)
cnx.close()
I used this code to check my mysql package that I installed using the installer provided by the mysql
I ran the file in terminal and the result was,
Traceback (most recent call last):
File "/Users/Krishna/Documents/check.py", line 1, in <module>
import mysql.connector
ImportError: No module named 'mysql'
Help is highly appreciated.
I don't think the mysql package is part of the MacOSX default install (it was not for me) for the built-in python.
You can solve this via pip
sudo pip install mysql-connector-repackaged
Verify by checking in the Python Library Path to see if you have a package for mysql there. To get your python path, do:
python
import sys
sys.path
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With