Hi everybody,
I am working on my graduate (final :)) exam, and SQLAlchemy is main
topic.
I was tryinig example from ORM tutorial:
>>> from sqlalchemy import select, func
>>> session.query(User).from_statement(
... select(
... [users_table],
...
select([func.max(users_table.c.name)]).label('maxuser')==users_table.c.name)
... ).all()
[<User('wendy','Wendy Williams', 'foobar')>]
And this looks too ugly for me, and not only that, I think that it is
not O.K. to use table and columns in ORM (at least I should have an
alternative way doing it without table and column objects).
So I tried something this (in my example User is Client):
>>> session.query(Client).from_statement(
... select(
... [Client],
... select([func.max(Client.name)]).label('max_name') ==
Client.name)
... ).all()
but, it is not working, the problem is in first argument of select.
Then I tried Client.c as first argument, but without success.
Only this works:
>>> session.query(Client).from_statement(
... select(
... Client.c._data.values(),
... select([func.max(Client.name)]).label('max_name') ==
Client.name)
... ).all()
but it is so ugly hack.
Is it some better way of doing this?
Sorry for my bad English :)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---