I have this funtion to delete a record from a MySQL table:
def delUser(): #Delete user #Ask for user to delete Username = raw_input('Which user would you like to delete? ') #Delete user delUser = '''DELETE FROM Users WHERE Username = %s''' cursor.execute(delUser,(Username)) db.commit()
The problem is that it makes nothing if the selected user (Username) does not exist. In case the user does not exist, I would like the function to print an error (something like "User does not exist. Try again", and go back to the raw input line. How can I do it?