I wrote some table ORM in SqlAlchemy, and I want to share common functionality between them, this is my table ORM:
class RetailCampaignTemp(Base, Serialize, PrimaryField):
__tablename__ = 'retail_campaign_temp'
clicks = Column(INTEGER(11))
id = Column(INTEGER(11), primary_key=True)
Here are my custom functions:
class Serialize(object):
def Serialize(self):
return {c: getattr(self, c) for c in inspect(self).attrs.keys()}
class PrimaryField(object):
@declared_attr
def GetPrimaryField(cls):
yield from (column for column in cls.columns if column.primary_key)
When I call RetailCampaignTemp.GetPrimaryField() it say 'generator' object is not callable, what does this mean?