mg wrote:
>
> I am using the declarative extension and have a class like this:
> class EmmaMember(Base):
> __tablename__ = 'members'
> id = Column('id', Integer(),
> Sequence('member_seq'), primary_key=True,
> nullable=False)
> account_id = Column('account_id', Integer() )
> email = Column('email', String() )
> member_since = Column(',ember_since', DateTime(timezone=False),
> default=func.now() )
>
> One of the things I would like to do is to order a query by the email
> domain, or by the email mailbox. Is there any easy way to do this with
> the session and orm?
>
> Here is an example sql query that does what I am looking for:
>
> select id, email, SPLIT_PART(LOWER(email), '@', 1) AS mailbox,
> SPLIT_PART(LOWER(email), '@', 2) AS domain
> from members order by mailbox desc;
>
>
functions like the above are available via the func. construct, i.e.
func.split_part(func.lower(MyClass.email), '@', 1), etc. that can go
right into the order_by() method of Query or select().
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---