connection pymysql.connect(host localhost , user root , db student , charset utf8 , passwd as123 as123 )
# 获取cursor 数据库执行对象
cursor connection.cursor()
#定义sql
sql select*from student
#执行sql语句
students cursor.execute(sql)
#通过fetchall获得所有的数据
result cursor.fetchall()
print(result)
# 关闭链接
connection.close()