sqlalchemy:如何通過一個查詢連接多個表?

| | | | | | | | | | |

我有以下 SQLAlchemy 映射類:

class User(Base): __tablename__ = "users" email = Column(String, primary_key=True) name = Column(String) class Document (Base): __tablename__ = "documents" name = Column(String, primary_key=True) author = Column(String, ForeignKey("users.email")) class DocumentsPermissions(Base): __tablename__ = "documents_permissions" readAllowed = Column(Boolean ) writeAllowed = Column(Boolean) document = Column(String, ForeignKey("documents.name")) 

我需要為 user.email = " [email protected]":

email |姓名 |文件名 | document_readAllowed | document_writeAllowed 

如何使用 SQLAlchemy 的一個查詢請求來實現?下面的代碼對我不起作用:

result = session.query(User, Document, DocumentPermission).filter_by(email = "[email protected]").all() 

謝謝,