Closed

Description
Hi
Run this SQL command using mysqlclient
:
CREATE TABLE IF NOT EXISTS `test`
(
`id` INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY
)
ENGINE=InnoDB;
for the first call it will run properly, but from the second call, it will rise Commands out of sync; you can't run this command now
error.
I run it like this:
db = MySQLdb.connect([...])
db.cursor().execute(command)
NOTE: calling with cursor.close()
, db.commit()
or etc, also have the same result.
OK, now try this command:
SELECT 1; -- this line will solve the error!
CREATE TABLE IF NOT EXISTS `test`
(
`id` INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY
)
ENGINE=InnoDB;
As you see the problem solved!
I've tested this also on other drivers like mysqljs/mysql
, this only happens on your driver.
It seems it is cause we use IF NOT EXISTS
clause and MySQL from second call cause of existence of the table, doesn't do anything and mysqlclient
doesn't fetch any result so MySQL rises this error.
el1s7
Metadata
Metadata
Assignees
Labels
No labels