7.30. Query About

7.30.1. Query

7.30.2. With Session

7.30.3. Select Columns

>>> from sqlalchemy.orm import defer
>>> from sqlalchemy.orm import undefer
>>> session.query(Book).options(
...     defer('*'), undefer('summary'), undefer('excerpt'))

A similar function is available with less verbosity by using the load_only() option. This is a so-called exclusionary option which will apply deferred behavior to all column attributes except those that are named:

>>> from sqlalchemy.orm import load_only
>>> session.query(Book).options(load_only(Book.summary, Book.excerpt))