diff --git a/libs/fingerprint.py b/libs/fingerprint.py index 7abb553..cf1a773 100644 --- a/libs/fingerprint.py +++ b/libs/fingerprint.py @@ -6,6 +6,7 @@ import json import sqlite3 import hashlib import time +import logging from libs import toolbox from libs.exceptions import FingerprintWrite @@ -132,13 +133,14 @@ class DBSchema: try: fh = open(file_json, "r") jsonData = json.load(fh) - dbmt = jsonData['db-metadata'] tb = jsonData['tables'] + dbmt = jsonData['db-metadata'] + dbht = jsonData['db-metadata-hashes'] all_tables = tb.keys() for table_name in all_tables: print "[[ Table <" + table_name + "> imported ]]" newTable = TableDefinition() - newTable.importTable(table_name, dbmt[table_name], tb[table_name]) + newTable.importTable(table_name, tb[table_name], dbmt[table_name], dbht[table_name]) tables[table_name] = newTable except Exception, e: @@ -148,6 +150,9 @@ class DBSchema: return tables + def __DBMD5Compare(self): + pass + def __DBSchemaCompare(self): # the json database schema definition is what our tools is expecting... # ...so we use it as the baseline @@ -162,6 +167,7 @@ class DBSchema: print "[[ Comparing Table: " + tableName + " ]]" if (table): if not (self.tablesJson[tableName].hash() == table.hash()): + logging.info("*** Hash difference 1:{}!={}".format(self.tablesJson[tableName].hash(), table.hash())) (total, diff_num) = self.__CompareTable(self.tablesJson[tableName], table) all_total += total diff_total += diff_num @@ -343,10 +349,11 @@ class TableDefinition: del newField['name'] # - def importTable(self, tbName, sqlStr, fields): + def importTable(self, tbName, fields, sqlStr, hashStr): self.tableName = tbName self.sqlStr = sqlStr self.fields = fields + self.sqlStrHash = hashStr # Table Definition