WIP: __readDatabase()

This commit is contained in:
JohnE 2016-02-23 12:12:04 -08:00
parent f738006147
commit b06b5ae4c4
3 changed files with 19 additions and 5 deletions

View File

@ -70,7 +70,8 @@ def compareFingerprintDir(file_in, fp_dir):
fp.openIndex(fp_dir)
# search for fingerprints with exact database match
fp_ret = fp.findFP(db.getMD5DB())
# fp_ret = fp.findFP(db.getMD5DB())
fp_ret = None
if (fp_ret):
print "Database matche(s) found"
print "RESULTS:"
@ -80,6 +81,7 @@ def compareFingerprintDir(file_in, fp_dir):
print
# search for fingerprints with similar tables
else:
logging.info("Searching for md5 tables: {}".format(db.getMD5Tables()))
fp_list = fp.findFPTables(db.getMD5Tables())
results = []
for fp in fp_list:

View File

@ -74,13 +74,16 @@ class FingerprintDB:
self.__readDatabase()
# concat all the table create statements, then md5
self.__createMD5DB()
except Exception, ex:
except Exception as ex:
logging.error(ex)
return -3
# create and index of table hashes
self.table_hashes = {}
print "*****"
print self.tables
for key in self.tables.keys():
print self.tables[key]
self.table_hashes[key] = self.tables[key].hash()
# flag is used to determine if the class has data
@ -275,12 +278,21 @@ class FingerprintDB:
# read a sqlite database by parsing the create table strings
# sqlmaster = "SELECT name, sql FROM sqlite_master WHERE type='table'"
def __readDatabase(self):
for row in self.cur.execute(self.sqlmaster):
rows = self.cur.execute(self.sqlmaster)
row = self.cur.fetchone()
if (not row):
raise Exception
newTable = TableSchema()
newTable.loadTable(row[0], row[1])
self.table_names.append(newTable.name())
self.tables[newTable.name()] = newTable
for row in rows:
newTable = TableSchema()
newTable.loadTable(row[0], row[1])
self.table_names.append(newTable.name())
self.tables[newTable.name()] = newTable
return
#
def debugFingerprint(self):

View File

@ -82,8 +82,8 @@ class FingerprintIndex:
# return an a list of json fingerprint files to open
def findFPTables(self, md5_tables):
retval = {}
for md5_table in md5_tables:
retval = {}
rows = self.__qTableMD5(md5_table)
for row in rows:
fp_list = row[0]