0

So For Some Reason This SQL Data Base Doesn't Update It's Arguments

def update_values(users_name, changed_name, changed_nickname, changed_age, changed_email): cursor.execute("SELECT * FROM User_Data1") # Change User_Data1 to get values from different tables data = cursor.fetchall() print("First Values:") for i in data: time.sleep(.10) print(i) cursor.execute(""" UPDATE User_Data1 SET Name =: updated_name AND Nickname = :updated_nickname AND Email = :updated_email AND Age = :updated_age WHERE Name = :first_name """, {'first_name': users_name, 'updated_name': changed_name, 'updated_nickname': changed_nickname, 'updated_email': changed_email, 'updated_age': changed_age}) # DOESN'T UPDATE FOR A REASON!? connection.commit() cursor.execute("SELECT * FROM User_Data1") # Change User_Data1 to get values from different tables data = cursor.fetchall() print("Updated Values:") for i in data: time.sleep(.10) print(i) So let's say we do this: update_values('Michael Jackson', 'Michelle Jacky', 'XXXDestroyerXXX', 30, 'blabla__bla@hotmail.com') Output is like this: First Values: ('Michael Jackson', 'Michelle Jacky', 'XXXDestroyerXXX', 'blabla__bla@hotmail.com', 30) Updated Values: ('Michael Jackson', 'Michelle Jacky', 'XXXDestroyerXXX', 'blabla__bla@hotmail.com', 30)

24th Sep 2018, 5:43 PM
Tuna Akın
Tuna Akın - avatar
1 ответ
+ 1
Please try: UPDATE User_Data1 SET Name = :updated_name, Nickname = :updated_nickname, Email = :updated_email, Age = :updated_age instead of this: UPDATE User_Data1 SET Name =: updated_name AND Nickname = :updated_nickname AND Email = :updated_email AND Age = :updated_age WHERE Name = :first_name """, (separate the fields, which should be updated, with a comma and not with AND)
2nd Oct 2018, 6:39 PM
P.W.R.
P.W.R. - avatar