1. pymysql在8.0版本以前(不包含8.0)是默认可以同时执行多条sql语句的,但是在8.0之后不再设置为默认,需要手动配置
2. 配置方法是在获取数据连接时,配置参数
示例代码:
import pymysql from pymysql.constants import CLIENT conn = pymysql.Connection( host='localhost', port=3306, user='root', password='db', database='data_job', charset='utf8', client_flag=CLIENT.MULTI_STATEMENTS # 添加client_flag参数 )
相关资源:https://github/PyMySQL/PyMySQL/blob/v0.9.3/CHANGELOG#L66 https://stackoverflow/questions/58544640/pymysql-unable-to-execute-multiple-queries
更多推荐
pymysql 同时执行多条sql语句
发布评论