10bet网址
MySQL连接器/Python开发者指南
相关的文档10bet官方网站 下载本手册

10.5.16 MySQLCursor。with_rows财产

语法:

Boolean = cursor.with_rows

这个只读属性返回真正的指示最近执行的操作是否可以生成行。

with_rows当需要确定语句是否生成结果集并且需要获取行时,此属性非常有用。属性返回的行选择语句的受影响行值,但仅报告更新声明:

进口mysql。连接器CNX = mysql.connector。connect(user='scott', database='test') cursor = cnx.cursor() operation =' SELECT 1;更新t1 SET c1 = 2;为光标中的结果选择2'。execute(operation, multi=True): if结果。with_rows: result.fetchall() else: print("Number of affected rows: {}".format(result.rowcount))