Hi, everyone.
It is my first time to ask for help here.
I use Python 3.4 to try save some imaging file to the longblob field of mysql table. The codes are:
====
import mysql.connector
filename = 'd:/12.jpeg'
print(filename)
f = open(filename, 'rb')
photo = f.read()
f.close()
mydb = mysql.connector.connect(host = '192.168.1.15', database = 'simon', user = 'simon', password = '1234')
mycur = mydb.cursor()
mycur.execute("insert into brand (imaging) values ('%s')", ([photo]))
mydb.commit()
mycur.close()
mydb.close()
======
When I run the code, it is always responsed some error message:
====
mysql.connector.errors.ProgrammingError: 1064 (42000): 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 '???' at line 1
====
I really need help for this matter.
Thank you in advance.
Simon
It is my first time to ask for help here.
I use Python 3.4 to try save some imaging file to the longblob field of mysql table. The codes are:
====
import mysql.connector
filename = 'd:/12.jpeg'
print(filename)
f = open(filename, 'rb')
photo = f.read()
f.close()
mydb = mysql.connector.connect(host = '192.168.1.15', database = 'simon', user = 'simon', password = '1234')
mycur = mydb.cursor()
mycur.execute("insert into brand (imaging) values ('%s')", ([photo]))
mydb.commit()
mycur.close()
mydb.close()
======
When I run the code, it is always responsed some error message:
====
mysql.connector.errors.ProgrammingError: 1064 (42000): 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 '???' at line 1
====
I really need help for this matter.
Thank you in advance.
Simon