""" Auther:少校 Time:2025/4/18 14:21 越努力,越幸运 """ import pymysql from csv import writer sql1 = pymysql.connect( user='root', #用户名 password='shaoxiao', #密码 host='127.0.0.1', #IP地址 port=3306, #端口号 database='school', #默认连接数据库/多个数据库默认哪个 charset='utf8mb4', #编码 autocommit=False #是否自动提交,默认关 ) s1 = sql1.cursor() # 补充:分页查询 start = 0 page = 5 while True: result = s1.execute('select * from students limit %s,%s;', (start,page)) sql1.commit() f = open(r"./students.csv", 'a', encoding='utf-8', newline="") w1 = writer(f) w1.writerows(s1.fetchall()) f.close() start += page if result < page : break
16.数据下载
本节777字2025-04-18 17:10:27