Possible to specify class without specifying __tablename__ in sqlalchemy?

python, sqlalchemy

Solution

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)

Problem

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?

Original source