pymysql 库

import pymysql
connect=pymysql.connect(host="172.7.200.2",port=3306,user="root",passwd="123",db="mysql",charset="utf8")
 
cursor=connect.cursor(pymysql.cursors.DictCursor)
sql="select user,host from mysql.user where user=%s and host=%s"
 
row=cursor.execute(sql,("root","%"))
info=cursor.fetchone()
 
print(info)
#cursor.commit()
cursor.close()
connect.close()
posted @ 2022-01-12 22:05  mingtian是吧  阅读(23)  评论(0编辑  收藏  举报