2
멀티미디어 아카이브 데이터베이스 백엔드를 작성 중이며 조인 된 테이블 상속을 사용하고 싶습니다. 필자는 Python을 SQLAlchemy와 함께 선언적 확장과 함께 사용하고 있습니다.SQLAlchemy - 매퍼 구성 및 선언적베이스
_Base = declarative_base()
class Record(_Base):
__tablename__ = 'records'
item_id = Column(String(M_ITEM_ID), ForeignKey('items.id'))
storage_id = Column(String(M_STORAGE_ID), ForeignKey('storages.id'))
id = Column(String(M_RECORD_ID), primary_key=True)
uri = Column(String(M_RECORD_URI))
type = Column(String(M_RECORD_TYPE))
name = Column(String(M_RECORD_NAME))
열 type
가 판별이며 다음과 같이 기록 매체 유지 테이블이다. 이제 udioRecord 자식 클래스를 Record
클래스에서 정의하고 싶습니다. 그러나 선언문 구문을 사용하여 다형성 매퍼 을 설정하는 방법을 모르겠습니다. 나는 (SQLAlchemy의 문서에서) 다음 코드에 대한 동등한를 찾고 있어요 :
mapper(Record, records, polymorphic_on=records.c.type, polymorphic_identity='record')
mapper(AudioRecord, audiorecords, inherits=Record, polymorphic_identity='audio_record')
내가 선언적 확장에 의해 생성 된 매퍼에 polymorphic_on
, polymorphic_identity
및 inherits
키워드를 전달할 수있는 방법 ?
내가 마지막으로 설명서에서 답을 발견하면 월
나는 당신이 SQLAlchemy의 메일 링리스트에 마이크를 묻는 것이 더 낫다, 그는 정말 도움이 생각합니다. –