How can I update a row\'s information?
For example I\'d like to alter the name column of the row that has the id 5.
In RestApi, We can update the record dynamically by passing the json data into update query:
class UpdateUserDetails(Resource):
@auth_token_required
def post(self):
json_data = request.get_json()
user_id = current_user.id
try:
userdata = User.query.filter(User.id==user_id).update(dict(json_data))
db.session.commit()
msg={"msg":"User details updated successfully"}
code=200
except Exception as e:
print(e)
msg = {"msg": "Failed to update the userdetails! please contact your administartor."}
code=500
return msg