CONECTAR COM MYSQL – PYTHON

import mysql.connector

mydb = mysql.connector.conect(
host=”localhost”,
user=”SeuUsuario”,
passwd=”SuaSenha”,
database=’SeuBanco’
)
mycursor = mydb.cursor()

mycursor.execute(“SELECT * FROM customers”)
# or
# mycursor.execute(“SELECT name, address FROM customers”)
myresult = mycursor.fetchall()
for x in myresult:
print(x)