On Fri, Feb 9, 2018 at 6:45 AM, Jeremy Flowers
wrote:
> Also this didn't work for me:
>
> print(session.query(Jobmst)
> .values(Jobmst.jobmst_type,
> Jobmst.jobmst_name)
> .first()
> )
>
> yields:
> AttributeError: 'generator' object has no attr
Out of interest, why would you not write:
print(
session.query(Jobmst.jobmst_type, Jobmst.jobmst_name)
.first()
)
The call to with_entities seems unnecessary.
Simon
On Fri, Feb 9, 2018 at 12:27 PM, Jeremy Flowers
wrote:
> And that can be simplified to:
> print(session.query()
>
And that can be simplified to:
print(session.query()
.with_entities(Jobmst.jobmst_type, Jobmst.jobmst_name)
.first()
)
On Friday, 9 February 2018 12:21:37 UTC, Jeremy Flowers wrote:
>
> Hi Simon.
> Instead of using values(), I did this.
> print(session.query(Jobmst)
Hi Simon.
Instead of using values(), I did this.
print(session.query(Jobmst)
.with_entities(Jobmst.jobmst_type, Jobmst.jobmst_name)
.first()
)
and that worked a treat too.
Thanks.
On Friday, 9 February 2018 11:58:18 UTC, Simon King wrote:
>
> The chaining-friendl
The chaining-friendly method you are looking for is probably with_entities():
http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.query.Query.with_entities
Simon
On Fri, Feb 9, 2018 at 11:52 AM, Jeremy Flowers
wrote:
> From watching your videos I always thought some sort of query
The main point you should take from Mike's original reply is:
.values() is a weird method and it's pretty old, usually people
just set the columns up front
You probably shouldn't use it.
On Fri, Feb 9, 2018 at 11:45 AM, Jeremy Flowers
wrote:
> Also this didn't work for me:
>
> print(session