Python needs a MySQL driver to access the MySQL database, in case this driver is not installed you can install “MySQL Connector”. by using PIP.
Once “MySQL Connector” is installed, you can use the code below to connect your mysql database
mydb = mysql.connector.connect(
# you must create a Cursor object. It will let # you execute all the queries you need cur = mydb.cursor() # Use all the SQL you like cur.execute("SELECT * FROM MY_TABLE_NAME") # print all the first cell of all the rows for row in cur.fetchall(): print row mydb.close()