Python 3 获取 mysql execute 的影响行数


cursor.execute(sql1) 
conn.commit()
effectRow = cursor.rowcount
print(effectRow)

If it's the same, then zero. 

Otherwise, none zero. 

Belows are from: https://blog.csdn.net/ghostyusheng/article/details/77836056

-- MySQL 更新或插入后获取受影响行数

SELECT ROW_COUNT();

-- mysql 插入一条记录后获取插入记录的主键id

SELECT LAST_INSERT_ID();

发布了1715 篇原创文章 · 获赞 380 · 访问量 247万+

猜你喜欢

转载自blog.csdn.net/tony2278/article/details/104903002
今日推荐