主要代码:
pymysql.connert(host = ip地址 , user = '用户名' , passwd = '密码' , port = 端口号 , db = '数据库名' , charset = 'utf8'编码类型)
import pymysql
conn=pymysql.connect(host = 'localhost' ,user = 'root' ,passwd='root' ,port= 3306 ,db='nimte',charset='utf8')
cur = conn.cursor()
search = "select * from tests where id= 10001"
cur.execute(search)
data = cur.fetchall()
print(data)
cur.close()