我有以下 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 = "user@email.com"
的桌子:
email | name | document_name | document_readAllowed | document_writeAllowed
如何使用一个查询请求 SQLAlchemy? 下面的代码对我不起作用:
result = session.query(User, Document, DocumentPermission).filter_by(email = "user@email.com").all()
谢谢,