On Thu, Sep 14, 2017 at 12:07 PM, Ankur Kumar <ankur.kumar.o...@gmail.com> wrote: >> I'm reallly sorry. > > > Please also update line number 13 in api.py and api1_py as > > old : > output = session.query(model.Bug_Test.value).with_for_update('read').all() > > New: > output = session.query(model.Bug_Test.value).all() >
In model.py you've got this: SessionMaker = sessionmaker(bind=engine) Session = scoped_session(SessionMaker) scoped_session is a tool for managing thread-local sessions (http://docs.sqlalchemy.org/en/latest/orm/contextual.html). Each time you call Session(), you'll get the same session instance back, as long as you are in the same thread. Since you are never calling session.close(), every call to select_data will actually use the same transaction, which is probably why you are not seeing data that was inserted after that transaction began. Typically in a web application you want to ensure that each request starts with a clean session, and closes the session again at the end, so that transactions aren't shared between requests. http://docs.sqlalchemy.org/en/latest/orm/session_basics.html#session-faq-whentocreate I don't use Flask, so I don't know the best way to get it to do that, but I know there is a library which will do it for you: http://flask-sqlalchemy.pocoo.org/2.1/ If you don't want to use that library, you could at least see how it closes out sessions: https://github.com/mitsuhiko/flask-sqlalchemy/blob/master/flask_sqlalchemy/__init__.py#L851 Simon -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.