How do I specify the column that I want in my query using a model (it selects all columns by default)? I know how to do this with the sqlalchmey session: session.query(self.col1), but how do I do it with with models? I can’t do SomeModel.query(). Is there a way?
How do I specify the column that I want in my query using a
Share
You can use the
with_entities()method to restrict which columns you’d like to return in the result. (documentation)Depending on your requirements, you may also find deferreds useful. They allow you to return the full object but restrict the columns that come over the wire.