How do I select specific columns from a query. For example, just the User name and size of a photo from:
class User(Base):
__tablename__ = \'user\'
u
Specify what you want returned in .query()
. The first mapped column indicates the base table to query from.
session.query(User.real_name, Photo.size).join(User.photos).all()
This will get you a list of tuples like [('name', 12)]
for every photo.
Please consider searching the documentation briefly. It's author is very thorough.