Ok, i've tried both (and each separately), as in:
r1 = Report(number = 1, title = "The Bird")
r2 = Report(number = 2, title = "The Bucket")
session.add_all([r1, r2])
session.commit()
q = self.session.query(Report.title)
q.with_entities(Report.number)
q.add_columns(Report.number)
print q.all()
printing:
[(u'The Bird',), (u'The Bucket',)]
what i would like to see is:
[(u'The Bird', 1), (u'The Bucket', 2)]
or something similar.
Cheers, Lars
On Wednesday, September 4, 2013 1:24:28 PM UTC+2, Simon King wrote:
>
> On Wed, Sep 4, 2013 at 12:05 PM, lars van gemerden
> <[email protected]<javascript:>>
> wrote:
> > I think i must be reading over something, but:
> >
> > is there a way to delay the selection of attributes in a query;
> something
> > like
> >
> > >>> session.query(Person).filter(Person.age >
> > 100).select(Person.name).first()
> >
> > >>> (u"Ancient Bob",)
> >
>
> I'm not sure quite what you mean, but the with_entities method of
> Query would seem to be the closest to your example:
>
>
> http://docs.sqlalchemy.org/en/rel_0_8/orm/query.html#sqlalchemy.orm.query.Query.with_entities
>
>
> I assume you know you can also do this:
>
> session.query(Person.name).filter(Person.age > 100).first()
>
> You can also defer certain columns so that they will be loaded lazily:
>
>
> http://docs.sqlalchemy.org/en/rel_0_8/orm/mapper_config.html#deferred-column-loading
>
>
> Hope that helps,
>
> Simon
>
--
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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.