0

I have a method into my Repository class that receives a object that was not loaded from database but is populated with the right id and I want to update it into the database:

class Repository(object):
 def __init__(session):
  self.session = session

 def update(self, car):
  self.session.update(car)

There is no method update into session. Also if I use add method the record is not updated.

How can I update the object with SQLAlchemy?

1
  • Call self.session.commit() Commented Mar 2, 2018 at 1:23

1 Answer 1

1

i found it out. the right way to do it is to call session.merge(car)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.