Bud P. Bruegger wrote:

> Many thanks for the answer.
>
> Another hopefully quick question:
>
> Is it possible to select a subset of columns in a query of an
> Entity subclass?  Kind of
>
> EntitySubClass.query.select([EntitySubClass.c.col1,
>                             EntitySubClass.c.col2]).all()

Yes, there are several ways to do it.  In addition to the previous
link to the wiki about setting up deferred column groups, you can
manually define which columns get deferred/loaded at query time:

     from sqlalchemy.orm import defer

     ...

     class Person(Entity):
         name = Field(String(64))
         age = Field(Integer)
         life_story = Field(Text)
         giant_picture = Field(Binary)

     ...

     people = Person.query.options(
         defer('life_story'),
         defer('giant_picture')
     ).all()

Alternatively, you can drop down to the table objects themselves,
and manually create your query:

     from sqlalchemy import select

     results = select(
         [Person.table.c.name, Person.table.c.age]
     ).execute().fetchall()

     for result in results:
         print result[0], result[1]

I hope this helps!

--
Jonathan LaCour
http://cleverdevil.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to