[英]Why am I getting `expected an indented block`?
I'm trying to insert an image into MySQL with Python.我正在尝试使用 Python 将图像插入 MySQL。
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.运行此代码时,我得到expected an indented block
。
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你的行with open("file.txt...
应该全部缩进
but you also have broken strings ... in your execute statements但你也有断线......在你的执行语句中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.