How to turn off autoflush feature:
-
Temporary: you can use no_autoflush context manager on snippet where you query the database, i.e. in
X.testmethod:def test(self, session): with session.no_autoflush: q = session.query(X).filter(X._val == self._val) x = q.one() print('x={}'.format(x)) -
Session-wide: just pass
autoflush=Falseto your sessionmaker:return sao.sessionmaker(bind=engine, autoflush=False)()