I see the difference between getting an object (with all the columns)
and doing an SQL statement.
As fas as I can see, yes it is bounded.

The code is:

from sqlalchemy import *

metadata = MetaData()
docs = Table('docs', metadata)
docs.append_column(Column('DocID', Integer, primary_key=True))
docs.append_column(Column('Path', String(120)))
docs.append_column(Column('Complete', Boolean))

class Doc(object):
    def __init__(self, id, path, state):
        self.DocID = id
        self.Path = path
        self.Complete = state

    def __str__(self):
        return '(%s) %s %s' %(self.DocID, self.Path, self.Complete)

if __name__ == "__main__":
    mapper(Doc, docs)

    db = create_engine( 'sqlite:///mydb' )
    db.echo = False

    s = create_session(bind_to = db)
    q = s.query(Doc)



On Jul 25, 2:16 pm, svilen <[EMAIL PROTECTED]> wrote:
> On Wednesday 25 July 2007 15:01:59 alex.schenkman wrote:> Hello:
>
> > How do I get only a few columns from a query object?
>
> > q = session.query(Document).select_by(Complete=False)
>
> > would give me a list of rows (all columns) where Complete == False.
>
> this would give u a list of objects, not rows. Eventualy u can disable
> all references not to get loaded. query.select() takes a premade sql
> statement but it should have enough columns to construct the object.
>
> > I have seen the select([doc.c.name]) notation but it doesn't work
> > for me.
>
> these are plain sql constructs (non-ORM), a somewhat different beast.
>
> > select([docs.c.DocID]).execute()
>
> > Gives me:
> > sqlalchemy.exceptions.InvalidRequestError: This Compiled object is
> > not bound to any engine.
>
> is your table's metadata bound to an engine?


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

Reply via email to