import pymysql
conn = pymysql.connect(host="10.235.128.xx",user="root",
password="Test123.",port=3306,database="mysql")
cursor = conn.cursor()
cursor.execute("SELECT VERSION()")
print(cursor.execute('SHOW TABLES'))
result = cursor.fetchall()
cursor.execute('SHOW TABLES')
result1 = cursor.fetchmany(10)
使用.fetchall()方法获取查询到的第一条表单列表 result 结果
result2 = cursor.fetchone()
print(result)
print(result1)
print(cursor.execute('SHOW DATABASES'))
data = cursor.fetchall()
print('格式化输出{0}'.format(data[0]))
data = cursor.fetchone()
print("Database version : %s " % data)
conn.commit()
conn.close