camelot (sqlalchemy ORM을 사용)을 사용하여 회원 목록을 보유하는 프로그램을 만들고 있습니다. 서로 결혼하여 같은 테이블에서 일대일 관계를 의미하는 사람들이있을 것입니다."Join"in same table
class Person(Entity):
id = Column(Integer, primary_key=True)
firstname = Column(Unicode(30), nullable = False)
lastname = Column(Unicode(30), nullable = False)
member_no = Column(Integer)
marital_status = Column(Unicode(15))
marriage_date = Column(Date())
married_to = ... # Should be one to one with self
내가이 일을 시도 : 이것은 Person 클래스의 단순화 된 버전입니다
married_to = relationship("Person", uselist=False, backref="persons")
married_to_id = Column(Integer, ForeignKey('persons.id'))
을하지만 실패 :
내가 같은 테이블 내에서 가입 할 수 어떻게InvalidRequestError: One or more mappers failed to initialize - can't proceed with initialization of other mappers. Original exception was: Person.married_to and back-reference Person.persons are both of the same direction . Did you mean to set remote_side on the many-to-one side ?
, 또는 이것은 내가 사용하고있는 잘못된 접근법입니다. 그리고 제가 Person A와 B를 합치면 B가 자동으로 A와 합류합니다. (두 가지 모두 ...)
나는 분명히하고 싶습니다. : -/
한숨과 .... 1 대 1? 왜 결혼 생활은 일 일부일처 제를 의미합니까? – paddy
나는 이것을 만들 때 그것을 생각했다. 하지만 우리나라의 법에 따르면 일부 다처제는 허용되지 않습니다. 법률이 바뀌면 내 소프트웨어를 바꿀 것 같아 .-p –