def remove_session(ex=None):
    session.remove()

@app.route('/')
def example():
    pass
Using SQLAlchemy session from Flask raises "SQLite objects created in a thread can only be used in that same thread"