本文共 580 字,大约阅读时间需要 1 分钟。
我正在尝试创建一个基类,为方便起见,指定了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 does not have a __table__ or __tablename__ specified and does not inherit from an existing table-mapped class.
这种模式在sqlalchemy中是否可行?
转载地址:http://njncl.baihongyu.com/