mariadb.InterfaceError: 命令不同步;你现在不能运行这个命令

问题描述

每当游标有数据时我都可以调用 cnxn.commit() 但是当游标为空时它会抛出 cnxn.commit() mariadb.InterfaceError: Commands out of sync; you can't run this command Now 使用 cursor.execute("call getNames")

解决方法

解决方案是我不应该调用存储过程,而是像 cursor.execute("SELECT * FROM names")

那样手动传递查询