Python 在SQLAlchemy中,您能按关联记录的类型过滤多态关联模型吗?

Python 在SQLAlchemy中,您能按关联记录的类型过滤多态关联模型吗?,python,sqlalchemy,polymorphic-associations,Python,Sqlalchemy,Polymorphic Associations,我在SQLAlchemy中使用多态关联,如中所述。它也可以在SQLAlchemy源代码的examples目录中找到 鉴于此设置,我想查询与用户s关联的所有地址e。不是用户,而是任何用户 在原始SQL中,我可以这样做: select addresses.* from addresses join address_associations on addresses.assoc_id = address_associations.assoc_id where address_association

我在SQLAlchemy中使用多态关联,如中所述。它也可以在SQLAlchemy源代码的examples目录中找到

鉴于此设置,我想查询与
用户
s关联的所有
地址
e。不是
用户
,而是
任何用户

在原始SQL中,我可以这样做:

select addresses.* from addresses 
join address_associations 
on addresses.assoc_id = address_associations.assoc_id
where address_associations.type = 'user'
有没有一种方法可以使用ORM会话来实现这一点


我可以运行这个原始SQL,然后将Address类应用于结果中的每一行吗?

使用ORM的即席连接描述如下:

for address in sess.query(Address).join(Address.association).filter_by(type='users'):
    print "Street", address.street, "Member", address.member