Answers for "flask sqlalchemy query specific columns"

0

flask sqlalchemy query specific columns

## You can use the with_entities() method to restrict which columns you'd like to return in the result. (documentation)

result = SomeModel.query.with_entities(SomeModel.col1, SomeModel.col2)

## 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.
Posted by: Guest on October-30-2020

Python Answers by Framework

Browse Popular Code Answers by Language