WIP: __readDatabase()
This commit is contained in:
parent
f738006147
commit
b06b5ae4c4
4
dbfp.py
4
dbfp.py
|
@ -70,7 +70,8 @@ def compareFingerprintDir(file_in, fp_dir):
|
||||||
fp.openIndex(fp_dir)
|
fp.openIndex(fp_dir)
|
||||||
|
|
||||||
# search for fingerprints with exact database match
|
# 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):
|
if (fp_ret):
|
||||||
print "Database matche(s) found"
|
print "Database matche(s) found"
|
||||||
print "RESULTS:"
|
print "RESULTS:"
|
||||||
|
@ -80,6 +81,7 @@ def compareFingerprintDir(file_in, fp_dir):
|
||||||
print
|
print
|
||||||
# search for fingerprints with similar tables
|
# search for fingerprints with similar tables
|
||||||
else:
|
else:
|
||||||
|
logging.info("Searching for md5 tables: {}".format(db.getMD5Tables()))
|
||||||
fp_list = fp.findFPTables(db.getMD5Tables())
|
fp_list = fp.findFPTables(db.getMD5Tables())
|
||||||
results = []
|
results = []
|
||||||
for fp in fp_list:
|
for fp in fp_list:
|
||||||
|
|
|
@ -74,13 +74,16 @@ class FingerprintDB:
|
||||||
self.__readDatabase()
|
self.__readDatabase()
|
||||||
# concat all the table create statements, then md5
|
# concat all the table create statements, then md5
|
||||||
self.__createMD5DB()
|
self.__createMD5DB()
|
||||||
except Exception, ex:
|
except Exception as ex:
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
return -3
|
return -3
|
||||||
|
|
||||||
# create and index of table hashes
|
# create and index of table hashes
|
||||||
self.table_hashes = {}
|
self.table_hashes = {}
|
||||||
|
print "*****"
|
||||||
|
print self.tables
|
||||||
for key in self.tables.keys():
|
for key in self.tables.keys():
|
||||||
|
print self.tables[key]
|
||||||
self.table_hashes[key] = self.tables[key].hash()
|
self.table_hashes[key] = self.tables[key].hash()
|
||||||
|
|
||||||
# flag is used to determine if the class has data
|
# 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
|
# read a sqlite database by parsing the create table strings
|
||||||
# sqlmaster = "SELECT name, sql FROM sqlite_master WHERE type='table'"
|
# sqlmaster = "SELECT name, sql FROM sqlite_master WHERE type='table'"
|
||||||
def __readDatabase(self):
|
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 = TableSchema()
|
||||||
newTable.loadTable(row[0], row[1])
|
newTable.loadTable(row[0], row[1])
|
||||||
self.table_names.append(newTable.name())
|
self.table_names.append(newTable.name())
|
||||||
self.tables[newTable.name()] = newTable
|
self.tables[newTable.name()] = newTable
|
||||||
return
|
|
||||||
|
|
||||||
#
|
#
|
||||||
def debugFingerprint(self):
|
def debugFingerprint(self):
|
||||||
|
|
|
@ -82,8 +82,8 @@ class FingerprintIndex:
|
||||||
|
|
||||||
# return an a list of json fingerprint files to open
|
# return an a list of json fingerprint files to open
|
||||||
def findFPTables(self, md5_tables):
|
def findFPTables(self, md5_tables):
|
||||||
|
retval = {}
|
||||||
for md5_table in md5_tables:
|
for md5_table in md5_tables:
|
||||||
retval = {}
|
|
||||||
rows = self.__qTableMD5(md5_table)
|
rows = self.__qTableMD5(md5_table)
|
||||||
for row in rows:
|
for row in rows:
|
||||||
fp_list = row[0]
|
fp_list = row[0]
|
||||||
|
|
Loading…
Reference in New Issue