- primary process (python+sqlalchemy) that periodically check db (sleeps most of times)
- child processes that email db
- web application that email db
Problem would be that the primary process session does not appear to join up alterations in the db done outdoors that session. How can ensure it will? (by now i'm closing and reopening the session each time the procedure awakes and does its check).
I'm closing and reopening the session each time the procedure awakes and does its check
SQLAlchemy won't work such as this. Changes are monitored within the session.
someobj = Session.query(SomeClass).first()
Session internal cache. Whenever you do
someobj.attr = val, it marks the modification within the Session connected with someobj.
If you drawn object1 from some session1, then closed session1, object1 isn't connected with any session any longer and isn't monitored.
Best answer is always to commit right upon the modification:
object1 = newsession.add(object1) newsession.commit()
Otherwise you'll have to manage own objects cache and merge these upon each check.