语法适用于MySQL,但不适用于MYSQL DB连接器(Python)

这是我的第一个问题,对不起,如果有点混乱,我在MYSQL上执行了此查询

INSERT INTO ms_print_stock (product_code, product_name, product_stock, product_unit) SELECT * FROM ms_product WHERE product_code = %s

but it doesn't work on MYSQL DB Connector. However, if I changed %s to a value it works. it returns this error.

mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version
for the right syntax to use near '%s' at line 1

顺便说一下,这里是python的完整代码

self.mycursor = self.mydb.cursor()
self.sql_print = "INSERT INTO ms_print_stock (product_code, product_name, product_stock, product_unit) SELECT * FROM ms_product WHERE product_code = %s"
print(self.sql_print)
self.val_print = (self.txtPCode.text())
self.mycursor.execute(self.sql_print, self.val_print)
print("BERHASIL")
self.mydb.commit()
评论