Given the following classes:
class DataAccessLayer():
def __init__(self):
self.engine = create_engine(CONN_STRING, pool_size=95, max_overflow=0)
self.connection = self.engine.connect()
class DataAccessLayerParallel(DataAccessLayer):
def __init__(self):
session_factory = sessionmaker(bind=self.connection)
I try to create an instance of DataAccessLayerParallel
as follows:
dal = DataAccessLayerParallel()
However, I get the error:
Exception has occurred: AttributeError
'DataAccessLayerNonParallel' object has no attribute 'connection'
I assume this is because the __init__
method from DataAccessLayer
does not run when it is inherited? How would I ensure I can get access to the connection
attribute?