query returning defines columns #447
Shaun-Hirst
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
is it possible to do a query that does not return all the columns.
i've tried using with_entities
query = SiteAddress.query.with_entities(
SiteAddress.account_code.label('account_code'), SiteAddress.site_id.label('site_id'),
SiteAddress.site_name.label('site_name'), SiteAddress.is_default.label('is_default'))
sites = query.filter(SiteAddress.account_code == account_code).all()
and load_only
sites = SiteAddress.query.options(load_only(
'account_code', 'site_id', 'site_name', 'is_default')).filter(SiteAddress.account_code == account_code).all()
but i either get all the columns for they don't return as a tuple so i'm not able to map them to the model
Beta Was this translation helpful? Give feedback.
All reactions