you would use deferred() on the mapping for this:
https://docs.sqlalchemy.org/en/13/orm/loading_columns.html?highlight=deferred#deferred
On Mon, Jun 3, 2019, at 8:29 PM, Desmond Lim wrote:
> Hi All,
>
> I have a question which I think I know the answer to but I'd like to confirm.
>
> I have a table/model that when I return the objects or list of objects, I
> want all the columns (15 of them) to be returned except 2. Is there a way to
> do that? Currently, I'm doing this (as per documentation)
>
> session.query(User).options(load_only("first_name", "last_name", ......))
>
> for all my queries and it is rather tedious and just makes the codes look
> ugly.
>
> Is there a command that I can use for all queries that would return all by 2
> columns unless I tell it not to?
>
> Thanks.
> Desmond
>
>
>
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sqlalchemy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sqlalchemy/CAM%2BCzajYT0Dt0tTOjnn7hGcKL0E9UGHsB6RsCxHO6zFx_Oymfw%40mail.gmail.com
>
> <https://groups.google.com/d/msgid/sqlalchemy/CAM%2BCzajYT0Dt0tTOjnn7hGcKL0E9UGHsB6RsCxHO6zFx_Oymfw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sqlalchemy/a41cf2e3-8459-4554-b96f-f98c5a25d070%40www.fastmail.com.
For more options, visit https://groups.google.com/d/optout.