How to disable caching correctly in Sqlalchemy orm session?

前端 未结 4 521
执笔经年
执笔经年 2021-01-19 12:48

I have I thread in a daemon, that loops and performs the following query:

    try:
        newsletter = self.session.query(models.Newsletter).\\
                     


        
4条回答
  •  忘掉有多难
    2021-01-19 13:31

    Hmm I already found the answer, you apparently need to explicitly do session.commit() to get it to update, or you need to set autocommit=True on the session, through for example the sessionmaker.

    sessionmaker(bind=self.engine, autocommit=True)
    

    However I haven't tested the session.commit() way

    So this isn't a caching issue it seems to be just the way transactions work

提交回复
热议问题