一.安装pymysql模块

如果pycharm上有没有下载的库,可以直接在pycharm上搜索下载安装:
python中的pymysql模块python中的pymysql模块也可在命令行进入python解释器目录后,输入命令下载:
python中的pymysql模块

二.通过python操作数据库

1.连接数据库

python中的pymysql模块

2.创建游标对象

python中的pymysql模块

3.对数据库操作

1.创建表
python中的pymysql模块
运行结果:
python中的pymysql模块
2.插入数据python中的pymysql模块python中的pymysql模块
3.插入多条数据
python中的pymysql模块运行结果:
python中的pymysql模块

三.查询数据库

1.查询数据记录数

python中的pymysql模块python中的pymysql模块

2.获取下一条查询结果集

python中的pymysql模块运行结果:
python中的pymysql模块

3.获取指定个数查询结果集

python中的pymysql模块python中的pymysql模块

4.获取剩下所有的查询结果

python中的pymysql模块python中的pymysql模块

四.cursor.scroll的用法python中的pymysql模块python中的pymysql模块

python中的pymysql模块

相关文章: