0
Hello, I’ve been trying for a while to receive and insert an image that needs to be BLOB type in Mariadb bank with Flask. However, when I try to insert the image into the bank with flask I get the error:
Error: 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 'b'\x89PNG\r\n\x1a\n\
My code:
@app.route('/api/images', methods=['POST'])
def index():
print('request.data: ', request.data)
if request.data:
image = request.data
try:
# conexão com MariaDB
connection = mariadb.connect(**config)
# criando um cursor de conexão
cur = connection.cursor()
# executando a query sql
cur.execute(f"INSERT INTO images (image) VALUES({image})")
connection.commit()
connection.close()
return 'Sucessoooo!'
except mariadb.Error as e:
print(f"Error: {e}")
return f"Error: {e}"
app.run()
Someone can help me?