I have a database containing a large amount of product-data. In order not to query for every product (here for the product images of the product with id 3), like this
images = session.query(Images.filename).filter(Images.product_id==3).all()
I want to query the entire table once, hold it in memory and filter the Query based on my needs, like this
images = session.query(Images)
productImage = [image.filename for image in list(images.filter(Images.product_id==3))]
This works, but there is probably a better way. Of course, the object images has to be filtered to contain the row(s) containing the relevant data for the product with id 3. How can I grab the columnvalues for the column filename from those rows more elegantly?