Reputation: 375
I am trying to use the update function to change the favourite song and artist of a user logged into my system. The problem is however, that I can't seem to use 2 variables twice to both find and update the record. The relevant section of my code is below.
c.execute('''
UPDATE users
SET (favourite_artist, favourite_genre)
VALUES(?, ?)'''
(self.new_fav_artist_var, self.new_fav_genre_var),
'''
WHERE username=? AND password =?'''
(self.username_input, self.password_input))
The first section is the variables that contain the new data to be inputted into the table, and the second set of variables is to find the appropriate records for the user logged into the system. Assume for this that the username and password are correct and related to this user, as that has been validated at an earlier point.
How can I make this work?
Cheers, Josh.
Upvotes: 0
Views: 55
Reputation: 1269603
I'm expecting:
c.execute('''
UPDATE users
SET favourite_artist = ?,
favourite_genre = ?
WHERE username = ? AND password = ?''',
(self.new_fav_artist_var, self.new_fav_genre_var, self.username_input, self.password_input))
Upvotes: 1