python连接MySQL并进行数据查询
作者:互联网
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
标签:connector,python,0.0,MySQL,查询,mycursor,mysql,mydb 来源: https://blog.csdn.net/zhongkeyuanchongqing/article/details/117848840