Add model_mapper and model_table attributes to base importer class

This commit is contained in:
Lance Edgar 2016-04-21 13:39:51 -05:00
parent 2cfa543e05
commit 739629eab9

View file

@ -72,6 +72,22 @@ class Importer(object):
""" """
return self.model_class.__name__ return self.model_class.__name__
@property
def model_mapper(self):
"""
This should return the SQLAlchemy mapper for the model class.
"""
return orm.class_mapper(self.model_class)
@property
def model_table(self):
"""
Returns the underlying table used by the primary local data model class.
"""
tables = self.model_mapper.tables
assert len(tables) == 1
return tables[0]
@property @property
def simple_fields(self): def simple_fields(self):
""" """
@ -80,8 +96,7 @@ class Importer(object):
only applies to the local / target side, it has no effect on the only applies to the local / target side, it has no effect on the
upstream / foreign side. upstream / foreign side.
""" """
mapper = orm.class_mapper(self.model_class) return list(self.model_mapper.columns.keys())
return list(mapper.columns.keys())
@property @property
def supported_fields(self): def supported_fields(self):