# Buggy code
def __init__(self, config, **kwargs):
    """Initialise the historian.

    The historian makes two connections to the data store.  Both of
    these connections are available across the main and processing
    thread of the historian.  topic_map and topic_meta are used as
    cache for the meta data and topic maps.

    :param config: dictionary object containing the configurations for
                   this historian
    :param kwargs: additional keyword arguments. (optional identity and
                   topic_replace_list used by parent classes)
    """
    super(SQLHistorian, self).__init__(**kwargs)
    database_type = config["connection"]["type"]
    self.tables_def, table_names = self.parse_table_def(config)
    db_functs_class = sqlutils.get_dbfuncts_class(database_type)
    self.reader = db_functs_class(config["connection"]["params"], table_names)
    self.writer = db_functs_class(config["connection"]["params"], table_names)
    self.reader.setup_historian_tables()

    self.topic_id_map = {}
    self.topic_name_map = {}
    self.topic_meta = {}
    self.agg_topic_id_map = {}


# Traceback (AttributeError)
2016-10-26 15:44:11,091 (sqlhistorianagent-3.6.0 1179) <stderr> ERROR: Exception in thread Thread-2:
2016-10-26 15:44:11,091 (sqlhistorianagent-3.6.0 1179) <stderr> ERROR: Traceback (most recent call last):
2016-10-26 15:44:11,091 (sqlhistorianagent-3.6.0 1179) <stderr> ERROR:   File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
2016-10-26 15:44:11,091 (sqlhistorianagent-3.6.0 1179) <stderr> ERROR:     self.run()
2016-10-26 15:44:11,091 (sqlhistorianagent-3.6.0 1179) <stderr> ERROR:   File "/usr/lib/python2.7/threading.py", line 754, in run
2016-10-26 15:44:11,091 (sqlhistorianagent-3.6.0 1179) <stderr> ERROR:     self.__target(*self.__args, **self.__kwargs)
2016-10-26 15:44:11,091 (sqlhistorianagent-3.6.0 1179) <stderr> ERROR:   File "/home/building-testbed/volttron4-latest/volttron/platform/agent/base_historian.py", line 639, in _process_loop
2016-10-26 15:44:11,092 (sqlhistorianagent-3.6.0 1179) <stderr> ERROR:     self.record_table_definitions(self.volttron_table_defs)
2016-10-26 15:44:11,092 (sqlhistorianagent-3.6.0 1179) <stderr> ERROR:   File "/home/building-testbed/.volttron/agents/26d7b095-9e5d-43df-bdfa-7c551584efd0/sqlhistorianagent-3.6.0/sqlhistorian/historian.py", line 192, in record_table_definitions
2016-10-26 15:44:11,092 (sqlhistorianagent-3.6.0 1179) <stderr> ERROR:     self.writer.record_table_definitions(self.tables_def,
2016-10-26 15:44:11,092 (sqlhistorianagent-3.6.0 1179) <stderr> ERROR: AttributeError: 'SQLHistorian' object has no attribute 'writer'

# Fixed code
def __init__(self, config, **kwargs):
    """Initialise the historian.

    The historian makes two connections to the data store.  Both of
    these connections are available across the main and processing
    thread of the historian.  topic_map and topic_meta are used as
    cache for the meta data and topic maps.

    :param config: dictionary object containing the configurations for
                   this historian
    :param kwargs: additional keyword arguments. (optional identity and
                   topic_replace_list used by parent classes)
    """
    self.config = config
    self.topic_id_map = {}
    self.topic_name_map = {}
    self.topic_meta = {}
    self.agg_topic_id_map = {}
    self.tables_def = {}
    self.reader = None
    self.writer = None
    super(SQLHistorian, self).__init__(**kwargs)