Skip to content Skip to sidebar Skip to footer

Sqlalchemy Get Every Row The Matches Query And Loop Through Them

I'm new to Python and SQLAlchemy. I've been playing about with retrieving things from the database, and it's worked every time, but im a little unsure what to do when the select st

Solution 1:

Your query is correct, you just need to change the way you interact with the result. The method you are looking for is all().

application = Applications.query.filter_by(brochureID=brochure.id)
entries = application.all()

Solution 2:

the Usual way to work with orm queries is through the Session class, somewhere you should have a

engine = sqlalchemy.create_engine("sqlite:///...")
Session = sqlalchemy.orm.sessionmaker(bind=engine)

I'm not familiar with flask, but it likely does some of this work for you.

With a Session factory, your application is instead

session = Session()
entries = session.query(Application) \
          .filter_by(...) \
          .all()

Post a Comment for "Sqlalchemy Get Every Row The Matches Query And Loop Through Them"