1
이 내 기본 클래스sqlalchmey 클래스의 별명?
class Product(Base):
__tablename__ = 'PRODUCT'
__table_args__ = {'quote':False}
...
id = Column(Integer, name='id_prod', primary_key=True)
type = Column(String(100),name='id_typ_prod')
__mapper_args__ = {'polymorphic_on': type}
그래서이다, 당연히 우리는이 제품, 예를 들어,에서 확장 클래스의 번호를 가지고 전화 및 케이블, 그들 각각은 자체 테이블에 매핑됩니다.
class Phone (Product):
__tablename__ = 'PHONE'
...
이제 몇 가지 이유로 데이터베이스에 해당 테이블이없는 클래스 인 '별칭'클래스를 만들고 싶습니다. 이런 식으로 뭔가 :
class VapourWare(Product):
...
내가
class VapourWare(Product):
__tablename__ = 'PRODUCT'
__mapper_args__ = {'polymorphic_identity':'VapourWare'}
작동하는 것 같다 않는 경우. 그러나 그것은 옳은가 또는 권장 된 길인가? 나는 여기에 __tablename__ = 'PRODUCT'
을 반복하고있다.