Python 含糊不清的foreignkeyserror:Can';不确定之间的连接

Python 含糊不清的foreignkeyserror:Can';不确定之间的连接,python,orm,sqlalchemy,Python,Orm,Sqlalchemy,我一直在试图修复上述错误的基础上,在网上多个帖子,但我只是不能使它的工作 我的SQLAlchemy 1.3.3模型是: class User(Base): __tablename__ = 'user' user_email = Column(String(255), primary_key=True) user_name = Column(String(120)) user_pass = Column(String(120)) user_super =

我一直在试图修复上述错误的基础上,在网上多个帖子,但我只是不能使它的工作

我的SQLAlchemy 1.3.3模型是:

class User(Base):
    __tablename__ = 'user'

    user_email = Column(String(255), primary_key=True)
    user_name = Column(String(120))
    user_pass = Column(String(120))
    user_super = Column(INTEGER(11))
    company_id = Column(ForeignKey('company.company_id'), index=True)

    company = relationship('Company')


class UserIncompany(User):
    __tablename__ = 'userincompany'
    __table_args__ = (
        ForeignKeyConstraint(['branch_company', 'branch_id'], ['branch.company_id', 'branch.branch_id']),
        ForeignKeyConstraint(['dstcentre_company_id', 'dstcentre_branch', 'dstcentre_id'], ['procentre.company_id', 'procentre.branch_id', 'procentre.dstcentre_id']),
        ForeignKeyConstraint(['userrole_company', 'role_number'], ['userrole.company_id', 'userrole.role_number']),
        Index('fk_usercompany_userrole1_idx', 'userrole_company', 'role_number'),
        Index('fk_table2_dstcentre1_idx', 'dstcentre_company_id', 'dstcentre_branch', 'dstcentre_id'),
        Index('fk_table2_branch1_idx', 'branch_company', 'branch_id')
    )

    user_email = Column(String(255), ForeignKey('user.user_email'), primary_key=True, nullable=False)
    user_supervisor = Column(String(255), ForeignKey('user.user_email'), index=True)
    user_admin = Column(INTEGER(11))
    user_mancycles = Column(INTEGER(11))
    user_maninv = Column(INTEGER(11))
    user_manstock = Column(INTEGER(11))
    branch_company = Column(String(12))
    branch_id = Column(String(12))
    dstcentre_company_id = Column(String(12))
    dstcentre_branch = Column(String(12))
    dstcentre_id = Column(String(12))
    userrole_company = Column(String(12), nullable=False)
    role_number = Column(INTEGER(11), nullable=False)

    branch = relationship('Branch')
    dstcentre_company = relationship('Procentre')
    company_user = relationship("User", foreign_keys=[user_email])
    supervisor = relationship("User", foreign_keys=[user_supervisor])

    userrole = relationship('Userrole')
用户和用户之间的关系是一对一的。我指出用户_电子邮件是主键,也是这两种关系,但我仍然得到错误:

sqlalchemy.exc.AmbiguousForeignKeysError: Can't determine join between 'user' and 'usercompany'; tables have more than one foreign key constraint relationship between them. Please specify the 'onclause' of this join explicitly.
我试着在网上看了很多东西,但我就是做不到

谢谢你的帮助