MySQL连接器/Python发布说明
语法:
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))