I have used a function named InsertBlob to insert images in Mysql by letting users input the file path but the error i often get is " it must be of type list, tuple or dict"..is there a way to overcome the error or must i do one whole different coding to get what i want?
def InsertBlob(FilePath):
with open(FilePath, "rb") as File:
BinaryData = File.read()
SQLStatement = "INSERT INTO Images (Photo) VALUES (%s)".format(BinaryData)
print(SQLStatement)
MyCursor.execute(SQLStatement , BinaryData)
print("1.Insert Image\n2. Read Image")
MenuInput = input()
if int(MenuInput) == 1:
UserFilePath = input("Enter File Path: ")
InsertBlob(UserFilePath)