connect to mysql workbench python

Solutions on MaxInterview for connect to mysql workbench python by the best coders in the world

showing results for - "connect to mysql workbench python"
Javier
18 Oct 2016
1Press CTRL+C to copy import mysql.connector
2from mysql.connector import errorcode
3
4try:
5  cnx = mysql.connector.connect(user='scott',
6                                database='employ')
7except mysql.connector.Error as err:
8  if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
9    print("Something is wrong with your user name or password")
10  elif err.errno == errorcode.ER_BAD_DB_ERROR:
11    print("Database does not exist")
12  else:
13    print(err)
14else:
15  cnx.close()