[ActiveRecordMixin] model not persisted unless I call db.session.commit()
jonathanronen opened this issue · comments
When I call model.create(...)
, it isn't persisted in the database unless I call db.session.commit()
after. What am I doing wrong?
Nevermind, there's the session autosave thing and this makes sense. My bad.
@jonathanronen I'm facing a similar issue. How did you solve it?
@jonathanronen I'm facing a similar issue. How did you solve it?
I decorated my api methods (POST, PUT) with this:
def with_commit(f):
"""Decorator for API methods ensures DB commit after call.
"""
@wraps(f)
def decorated_function(*args, **kwargs):
res = f(*args, **kwargs)
db.session.commit()
return res
return decorated_function