""" Description: Author:Nod Date: Record: #---------------------------------v1-----------------------------------# """ import pymysql conn = pymysql.connect(host='172.30.2.118', port=3306, user='nod', passwd='nod', db='mysql') cursor = conn.cursor() cursor.execute("select host,password,user from user where user='nod'") # 获取剩余结果的第一行数据 row_1 = cursor.fetchone() print(row_1) # 获取剩余结果前n行数据 # row_2 = cursor.fetchmany(3) # 获取剩余结果所有数据 # row_3 = cursor.fetchall() # print(row_3) conn.commit() cursor.close() conn.close()