0

here is my query

 x.execute("UPDATE details SET name =%s,"(form.newname)"WHERE name =%s," (form.name))

am getting syntax error.can anyone pls help to fix it

2
  • Kill the comma after SET and add appropriate spacing: x.execute("UPDATE details SET name = %s"(form.newname)" WHERE name = %s" (form.name)) Commented Sep 29, 2016 at 7:02
  • i tried but same error. thanx for comment Commented Sep 29, 2016 at 7:04

3 Answers 3

1

Based on syntax: cursor.execute(sql_query, args)

It should be like:

x.execute("UPDATE details SET name = %s WHERE name = %s", (form.newname, form.name))
Sign up to request clarification or add additional context in comments.

1 Comment

execute() takes at most 3 arguments (4 given)...am getting like this error
0

If you want to update those name which is ending with the letter "s"

then you have to use LIKE operator in where clause

update destails set name ="adfsf" where name like '%s' 

1 Comment

am not trying to update names with letter s .i want to update name from form.name to form.new name<-(these are text boxes)
0

You can try :

x.execute("""UPDATE details SET name = "%s" WHERE name = "%s" """, (form.newname, form.name))

If form.newname and form.name are TEXT fields in database, you have to pass %s with parenthesis "%s"

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.