with open("face.jpg","rb") as f:
img_data=f.read()
find_binary=pymysql.Binary(img_data)
print(find_binary)
add_row="""INSERT INTO IMGS(ID,IMG,,DATAIMG) VALUES(7,"K1","NO.","%s")""" % (find_binary)
cursor.execute(add_row)
here are the reasons for the error
pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near "\\xff\\xd8\\xff\\xe0\\x00\\x10JFIF\\x00\\x01\\x01\\x01\\x00H\\x00H\\x00\\x00\\xff\\xdb\\x00C\\x00\\" at line 1")
seems to be grammatical or the output of pymysql.binary is not a binary file at all, but it is not clear what went wrong, and the DATAIMG type is mediumblob
.