O
O
Oleg Gamega2015-05-16 16:18:34
Flask
Oleg Gamega, 2015-05-16 16:18:34

Is there a saveOrUpdate hibernate equivalent in flask-sqlalchemy?

Hello.
If there is no entry with a certain id, I need to write it down, if there is, update it with new data.
Is there an analogue of saveOrUpdate hibernate in flask-sqlalchemy ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2015-05-16
@gadfi

stackoverflow.com/questions/5442825/save-or-update...

update(), save_or_update(), save() are all deprecated. add() places an object in the session in all cases, using the persistence information already associated with the object to determine INSERT or UPDATE. this means if you just make a new Foo(id=some id), that's transient - SQLAlchemy didn't load it. It will be INSERTed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question