I'm trying to insert an image into MySQL with Python.
import mysql.connector
import base64
conn = mysql.connector.Connect(user="root",passwd="solomon",host="localhost",db="binarymanipulation",port="3306")
cursor =conn.cursor;
with open('/home/solomon/Downloads/javapic.jpeg', 'rb') as image:
cursor.execute('INSERT INTO images(id,size,image) VALUES('PYTHON',245,image) ')
conn.commit();
conn.close();
I'm getting expected an indented block
while running this code.
What did I miss? What is the right way?
your first line should not have a space to lead it
your lines following with open("file.txt...
should all be indented
but you also have broken strings ... in your execute statements
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.