Why is it still "the commands are not synchronized, you cannot run this command now"

I am using the mysqldb library for Python to connect mysql db. I have a web server with 4 workflows that has 1 conn and 1 cursor for mysql db. therefore, each workflow will use its connection / cursor to execute the SQL statement.

Now I have several clients at the same time to send a request to the server, and the server will query mysql db and return some result to the client. I encountered an error. 2014, "Commands are not synchronized, you cannot run this command now."
I have a sql check, it's just like that SELECT a, b, c from table WHERE a = 1. There is no semicolon or repository, and I am also trying to use the code below Python, "commands are out of sync; you cannot run this command now . But this is still the same error.

self.cursor.execute(sql, data)
self.conn.commit()
result = result + self.cursor.fetchall()
self.cursor.close()
self.cursor = self.conn.cursor() 
+4
source share
1 answer

, . , , mysql, , , .

MySQL , . MySQLdb 2. Cursor ( mysql_store_result()), SSCursor ( mysql_use_result(); , , . , , , COMMIT ROLLBACK Connection. , . , .

: . , , , , , MySQL . , , , . , MySQL, , . .

+3

Source: https://habr.com/ru/post/1608772/


All Articles