1

I am trying to do a simple update in python. This the code I try to run:

 mycursor = mydb.cursor()
 if(result<5):
        os.remove(destiny)
        print(result)
        print(fi[:-4])
        print(lastid)
        sql = "UPDATE googlesearch SET similarity=%s WHERE tweetid=%d and imageName=%s"
        value = (str(result),lastid,str(fi[:-4]))
        print(value)
        mycursor.execute(sql, value)
        mydb.commit()

As you can see it is very easy. But when I run it, I have this error:

ProgrammingError: Not all parameters were used in the SQL statement

Printing values, I have this: ('2.82258064516129', 2636, 'dimg_10') And working in Navicat with this sentence, everything is perfect. So why, I have this error?.

3
  • 2
    Statement parameters positions are indicated by %s, not %d. Commented Jun 15, 2020 at 21:36
  • @khelwood That's an answer, not a comment Commented Jun 15, 2020 at 21:38
  • @pppery Yeah, I know. Bad habit. Commented Jun 15, 2020 at 21:41

1 Answer 1

1

Statement parameter positions are indicated by %s, not %d.

So I think if you change

sql = "UPDATE googlesearch SET similarity=%s WHERE tweetid=%d and imageName=%s"
                                                            ^

to

sql = "UPDATE googlesearch SET similarity=%s WHERE tweetid=%s and imageName=%s"
                                                            ^

you will avoid this error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.