import pymysql
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()
相关文章
- 08-09香橙派OrangePi zero2开发板连接3.5寸SPI LCD显示屏的使用方法
- 08-09SSIS读取脚本任务上的平面文件连接
- 08-09【SSIS】Foreach循环容器读取 xlsm 格式的文件时,连接管理器出错
- 08-09day05_DQL查询表中的数据(分组查询丶连接查询)③
- 08-09一个喜剧简单的python程序上的IRC连接错误
- 08-09不同速率光模块与光纤跳线的连接使用方案
- 08-09【Python实战】使用Python连接Teradata数据库???未完成
- 08-09物联网6类技术无线连接技术的分析
- 08-09数据库中的循环与游标
- 08-09java – Spring中的数据库写锁实体