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
>From watching your videos I always thought some sort of query object would
be returned from the query() operation, so method chaining (aka fluent
interface) could always be performed.. in a way that is analogous to
JQuery. But what I'm doing seems to be breaking that paradigm. What am I
doing
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 attribute 'first'
Swapping first to earlier in the chain like so:
print(ses
I was thinking about this overnight..
Do *values* relates specifically to inserts and updates, not
selects/deletes perhaps, which would correlate to SQL syntax.
If, it would make sense to indicate that in the documentation
On Thursday, 8 February 2018 20:29:45 UTC, Jeremy Flowers wrote:
>
> I'v