Skip to content

Conversation

@doylejg
Copy link

@doylejg doylejg commented Mar 30, 2022

I was using this example for a class and I wanted to use the newer syntax. I have a version that doesn't use the with .. : syntax if you prefer.

@doylejg
Copy link
Author

doylejg commented Mar 30, 2022

Let me know if you're interested in the other version. I tried to use realistic SQLAlchemy - Flask packaging paradigm without actually using multiple files. I also chose not to use the with syntax.

Here is a snippet

SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
app.session = scoped_session(SessionLocal)

...

@app.route("/")
def home():
    todo_list = app.session.execute(select(Todo)).scalars().all()
    return render_template("base.html", todo_list=todo_list)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant