我正在尝试创建一个基类,其中为方便起见指定了 id 和 url。
Base = declarative_base()
Base.query = session.query_property()
class CrawlableEntity(Base):
"""CrawlableEntity class for all entities crawled online.
"""
id = Column(Integer, primary_key=True)
url = Column(String, nullable=False)
class Model(CrawlableEntity):
__tablename__ = 'models'
name = Column(String) # Bobby Raffin
looks = relationship('Look', backref='model')
我收到以下错误
sqlalchemy.exc.InvalidRequestError: Class <class 'CrawlableEntity'> does not have a __table__ or __tablename__ specified and does not inherit from an existing table-mapped class.
这种模式在 sqlalchemy 中是否可行?