MOD: improved the table comparison, removed buggy code
This commit is contained in:
parent
5b683cb108
commit
9f8b791bca
|
@ -191,33 +191,29 @@ class FingerprintDB:
|
|||
# if exists, compare each field
|
||||
# else, add to unknown tables...or do a fuzzy compare (look at number of fields, field names)
|
||||
diff_num = 0
|
||||
diff_total = 0
|
||||
all_total = 0
|
||||
diff_total = 0 # total number of different properties (from within a table)
|
||||
all_total = 0 # total number of properties (from the entire database comparison)
|
||||
for tableName in fp.tables.keys():
|
||||
try:
|
||||
logging.info("[[ Comparing Table: " + tableName + " ]]")
|
||||
table = self.tables[tableName]
|
||||
if (table):
|
||||
print "***__DBMD5Compare:: hash1=={}, hash2=={}".format(fp.tables[tableName].hash(), table.hash())
|
||||
logging.info("__DBMD5Compare:: hash1=={}, hash2=={}".format(fp.tables[tableName].hash(), table.hash()))
|
||||
if not (fp.tables[tableName].hash() == table.hash()):
|
||||
logging.info("*** Hash difference 1:{}!={}".format(fp.tables[tableName].hash(), table.hash()))
|
||||
(total, diff_num) = self.__CompareTable(fp.tables[tableName], table)
|
||||
all_total += total
|
||||
diff_total += diff_num
|
||||
else:
|
||||
all_total += 10
|
||||
logging.info("Table {} is IDENTICAL (to json fingerprint)".format(tableName))
|
||||
else:
|
||||
self.__FuzzyTable()
|
||||
all_total += 10 # increment the total tables compared
|
||||
logging.info("__DBMD5Compare:: tableName=={} IDENTICAL".format(tableName))
|
||||
# table found in only one database (fingerprint)
|
||||
except KeyError as ex:
|
||||
# get the number of fields from the other table to add to the diff_total
|
||||
all_total += 10
|
||||
diff_total += 10
|
||||
logging.info("Table {} not EXISTS (to json fingerprint)".format(tableName))
|
||||
logging.info("__DBMD5Compare:: tableName=={} NOT FOUND".format(tableName))
|
||||
diff_total += 10 # increment the total of different properties
|
||||
all_total += 10 # increment the total tables compared
|
||||
self.__FuzzyTable() # TODO: try to detect table name changes, look for same properties
|
||||
|
||||
logging.info("diff_total=={}, all_total=={}".format(diff_total, all_total))
|
||||
|
||||
print "***__DBMD5Compare:: all_total=={}, diff_total=={}".format(all_total, diff_total)
|
||||
logging.info("__DBMD5Compare:: all_total=={}, diff_total=={}".format(all_total, diff_total))
|
||||
|
||||
if (diff_total > 0):
|
||||
if (diff_total == all_total):
|
||||
|
@ -256,12 +252,12 @@ class FingerprintDB:
|
|||
|
||||
totals = prop_total_count + fields_total_count
|
||||
diff_total = prop_error_count + fields_diff_count
|
||||
print ("***__CompareTable:: prop_total_count=={}, fields_total_count=={}, totals=={}".format(prop_total_count, fields_total_count, totals))
|
||||
print ("***__CompareTable:: prop_error_count=={}, fields_diff_count=={}, diff_total=={}".format(prop_error_count, fields_diff_count, diff_total))
|
||||
logging.info("__CompareTable:: prop_total_count=={}, fields_total_count=={}, totals=={}".format(prop_total_count, fields_total_count, totals))
|
||||
logging.info("__CompareTable:: prop_error_count=={}, fields_diff_count=={}, diff_total=={}".format(prop_error_count, fields_diff_count, diff_total))
|
||||
return (totals, diff_total)
|
||||
|
||||
# look at un-identified tables and try to match fields by their properties
|
||||
def __FuzzyTable():
|
||||
def __FuzzyTable(self):
|
||||
return
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue