I'm running Ubuntu 16.04, trying to connect to mysql in python:
import mysql
username = 'root'
cnx = mysql.connector.connect(user=username, database='db')
cnx.close()
But I get an error:
File "pysql1.py", line 4, in <module>
cnx = mysql.connector.connect(user=username, database='db')
AttributeError: module 'mysql' has no attribute 'connector'
I installed the mysql python module by downloading the package here. I tried sudo apt-get install python-mysql.connector
to no avail. Any pointers?
EDIT: after adding import mysql.connector
I got an unrelated permissions error which I've now resolved, so that's what I needed ty lots!!!