sqlalchemy-无法为映射表组装任何主键列

pos*_*ich 5 python sqlalchemy

我正在使用sqlalchemy来反映没有定义外键的现有数据库。给出以下示例:

engine = sqlalchemy.create_engine(...)
Base = declarative_base()
Base.metadata.reflect(engine)

class A(Base):
    __table__ = Base.metadata.tables['A']


class B(Base):
    __table__ = Base.metadata.tables['B']

class C(Base):
    __table__ = sqlalchemy.outerjoin(A, B, onclause=A.foo==B.foo)
Run Code Online (Sandbox Code Playgroud)

如何限制C中使用的字段?

我尝试设置:

__mapper_args__ = {
    'include_properties': ['foo', 'bar']
}
Run Code Online (Sandbox Code Playgroud)

但是得到错误

Mapper Mapper|C|Join object on Join object on Join object on A(47698852085840) and B(47698852088016)(47698861282384) could not assemble any primary key columns for mapped table
Run Code Online (Sandbox Code Playgroud)