Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Revisions

4 of 4
Commonmark migration

Python Formatting SQL WHERE clause

I'm having this function that communicates via pymysql to an SQL database stored to my localhost. I know there are similar posts about formatting an SQL section especially this one but could anyone suggest a solution? Always getting TypeError: can't concat tuple to bytes. I suppose it's sth with the WHERE clause.

def likeMovement(pID):
 print("Give a rating for the movement with #id:%s" %pID)
 rate=input("Give from 0-5: ")
 userID=str(1)
 print(rate,type(rate))
 print(pID,type(pID))
 print(userID,type(userID))
 cursor=con.cursor()
 sqlquery='''UDPATE likesartmovement SET likesartmovement.rating=%s WHERE 
 likesartmovement.artisticID=? AND likesartmovement.userID=?''' % (rate,), 
 (pID,userID)
 cursor.execute(sqlquery)

TypeError: not all arguments converted during string formatting

Thanks in advance!

default

AltStyle によって変換されたページ (->オリジナル) /