python连接MySQL并进行数据查询
#建立数据库的连接
mydb = mysql.connector.connect(
host="0.0.0.0",
user="root",
passwd="",
database="db_name"
)
#
#使用python连接MySQL并进行输出查询操作
import mysql.connector
# MySQl databses details
mydb = mysql.connector.connect(
host="0.0.0.0",
user="root",
passwd="",
database="db_name"
)
mycursor = mydb.cursor()
# Execute SQL Query =>>>> mycursor.execute("SQL Query")
mycursor.execute("SELECT column FROM table")
myresult = mycursor.fetchall()
for x in myresult:
prin