Dear List.
How do I do this more ormish?
The statement is supposed to find the latest messages which havent yet
been answered
by 123456, assuming a later message is an answer;-)
def play4():
print ############### play4 #################
engine=create_engine(dburi)
result=engine.execute("""
select m.fromid, s.name, m.sent from person s,message m
where toid=123456 and
s.personid = m.fromid and not exists (
select 1 from message k where
k.toid=m.fromid and k.fromid=m.toid
and k.sent > m.sent
)
order by m.sent desc
""")
...
I completely fail to grasp how I get from the straight sql-
representation to the part where i
can actually benefit from the orm
Here am I: I have created a mapper where each message knows it's
sender and receiver by foreign key and attribute like this (and this I
like very much):
message_mapper=mapper(
Message,
message_table,
properties={
"sender": relation(Person,
primaryjoin=(message_table.c.fromid==Person.c.personid)),
"receiver": relation(Person,
primaryjoin=(message_table.c.toid==Person.c.personid))
}
)
kind regards
jorgen
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---