I am trying to create a base class where id and url are specified for convenience.
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')
I am getting the following error
sqlalchemy.exc.InvalidRequestError: Class <class 'CrawlableEntity'> does not have a __table__ or __tablename__ specified and does not inherit from an existing table-mapped class.
Is this pattern possible in sqlalchemy?
See Abstract Concrete Classes:
class CrawlableEntity(Base):
"""CrawlableEntity class for all entities crawled online. """
__abstract__ = True
id = Column(Integer, primary_key=True)
url = Column(String, nullable=False)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With