@logExceptions(_LOGGER)<EOL><INDENT>def _initTables(self, cursor, deleteOldVersions, recreate):<DEDENT>
<EOL>if deleteOldVersions:<EOL><INDENT>self._logger.info(<EOL>"<STR_LIT>",<EOL>traceback.format_stack())<EOL>for i in range(self._DB_VERSION):<EOL><INDENT>cursor.execute('<STR_LIT>' %<EOL>(self.__getDBNameForVersion(i),))<EOL><DEDENT><DEDENT>if recreate:<EOL><INDENT>self._logger.info(<EOL>"<STR_LIT>",<EOL>self.dbName, traceback.format_stack())<EOL>cursor.execute('<STR_LIT>' % (self.dbName))<EOL><DEDENT>cursor.execute('<STR_LIT>' % (self.dbName))<EOL>cursor.execute('<STR_LIT>' % (self.dbName))<EOL>output = cursor.fetchall()<EOL>tableNames = [x[<NUM_LIT:0>] for x in output]<EOL>if '<STR_LIT>' not in tableNames:<EOL><INDENT>self._logger.info("<STR_LIT>", self.jobsTableName)<EOL>fields = [<EOL>'<STR_LIT>',<EOL>'<STR_LIT>' % (self.CLIENT_MAX_LEN),<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>' % (self.HASH_MAX_LEN),<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>'  %self.CMPL_REASON_SUCCESS,<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>' % self.DEFAULT_JOB_PRIORITY,<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>'  %self.CLEAN_NOT_DONE,<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>'<EOL>]<EOL>options = [<EOL>'<STR_LIT>',<EOL>]<EOL>query = '<STR_LIT>' %(self.jobsTableName, '<STR_LIT:U+002C>'.join(fields), '<STR_LIT:U+002C>'.join(options))<EOL>cursor.execute(query)<EOL><DEDENT>if '<STR_LIT>' not in tableNames:<EOL><INDENT>self._logger.info("<STR_LIT>", self.modelsTableName)<EOL>fields = [<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>' % (self.HASH_MAX_LEN),<EOL>'<STR_LIT>' % (self.HASH_MAX_LEN),<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>]<EOL>options = [<EOL>'<STR_LIT>',<EOL>]<EOL>query = '<STR_LIT>' %(self.modelsTableName, '<STR_LIT:U+002C>'.join(fields), '<STR_LIT:U+002C>'.join(options))<EOL>cursor.execute(query)<EOL><DEDENT>cursor.execute('<STR_LIT>' % (self.jobsTableName))<EOL>fields = cursor.fetchall()<EOL>self._jobs.dbFieldNames = [str(field[<NUM_LIT:0>]) for field in fields]<EOL>cursor.execute('<STR_LIT>' % (self.modelsTableName))<EOL>fields = cursor.fetchall()<EOL>self._models.dbFieldNames = [str(field[<NUM_LIT:0>]) for field in fields]<EOL>self._jobs.publicFieldNames = [self._columnNameDBToPublic(x)<EOL>for x in self._jobs.dbFieldNames]<EOL>self._models.publicFieldNames = [self._columnNameDBToPublic(x)<EOL>for x in self._models.dbFieldNames]<EOL>self._jobs.pubToDBNameDict = dict(<EOL>list(zip(self._jobs.publicFieldNames, self._jobs.dbFieldNames)))<EOL>self._jobs.dbToPubNameDict = dict(<EOL>list(zip(self._jobs.dbFieldNames, self._jobs.publicFieldNames)))<EOL>self._models.pubToDBNameDict = dict(<EOL>list(zip(self._models.publicFieldNames, self._models.dbFieldNames)))<EOL>self._models.dbToPubNameDict = dict(<EOL>list(zip(self._models.dbFieldNames, self._models.publicFieldNames)))<EOL>self._models.modelInfoNamedTuple = collections.namedtuple(<EOL>'<STR_LIT>', self._models.publicFieldNames)<EOL>self._jobs.jobInfoNamedTuple = collections.namedtuple(<EOL>'<STR_LIT>', self._jobs.publicFieldNames)<EOL>return<EOL>
Initialize tables, if needed

        Parameters:
        ----------------------------------------------------------------
        cursor:              SQL cursor
        deleteOldVersions:   if true, delete any old versions of the DB left
                              on the server
        recreate:            if true, recreate the database from scratch even
                              if it already exists.