今天在用程序连mysql执行多条sql语句的时候,报的错误:Commands out of sync; you can’t run this command now
问题原因如下:
master_slq = [
'STOP SLAVE;' # 这行结尾没有逗号,导致sql执行报错
'RESET SLAVE ALL;',
'set global read_only=off;']
for m in master_slq:
master_cursor.execute(m)
在sql语句都是正确的情况下,我是两条sql语句中间没有用逗号隔开导致的,属于编码不严谨。