WIP: problem inserting a row into database, troubleshooting

This commit is contained in:
JohnE 2015-12-10 12:48:13 -08:00
parent 8653b56e86
commit 7736404c30
2 changed files with 21 additions and 21 deletions

View File

@ -149,17 +149,16 @@ class FingerprintDB:
dbmd5 = jsonData['db-metadata-md5']
all_tables = tb.keys()
for table_name in all_tables:
print "[[ Table <" + table_name + "> imported ]]"
#logging.info("[[ Table <" + table_name + "> imported ]]")
newTable = TableSchema()
newTable.importTable(table_name, tb[table_name], dbmt[table_name], dbht[table_name])
tables[table_name] = newTable
except Exception, e:
logging.error("ERROR: problem loading json file: " + file_json + e)
self.tables_json = tables
self.db_hash = dbmd5
self.table_hashes = dbht
except Exception as e:
logging.error("ERROR: problem loading json file: " + file_json + e)
#
def __DBMD5Compare(self):

View File

@ -53,6 +53,8 @@ class FingerprintIndex:
file_name TEXT);
''')
logging.info("Successfully created index table")
self.__populateIndex(fp_dir)
logging.info("Successfully populated the index")
except:
raise FingerprintIndexWrite("Error creating an index file")
finally:
@ -60,12 +62,9 @@ class FingerprintIndex:
self.db_conn.close()
self.db_conn = None
self.__populateIndex(fp_dir)
def __populateIndex(self, fp_dir):
#
# read each file, pull md5, add row to database
def __populateIndex(self, fp_dir):
""" read each file, pull md5, add row to database """
failCount = 0
finCount = 0
try:
@ -75,12 +74,13 @@ class FingerprintIndex:
for file in files:
try:
fq_file = fp_dir + os.path.sep + file
print ("importJson file=={}".format(fq_file))
# print ("importJson file=={}".format(fq_file))
db.importJson(fq_file)
print("db_hash=={}".format(db.db_hash))
print("table_hashes={}".format(db.table_hashes))
self.__insertRecord(db.db_hash, db.table_hashes.values(), file)
# print("db_hash=={}".format(db.db_hash))
# print("table_hashes={}".format(db.table_hashes))
#md5_all = __createMD5Index(dbht)
return
finCount = finCount+1
except:
failCount = failCount+1
@ -88,17 +88,18 @@ class FingerprintIndex:
pass
logging.info("Completed populating the index. Completed: {} Failed: {} ".format(str(finCount), str(failCount)))
#
def __insertRecord(self, md5_all, md5_list, filename):
try:
logging.info("INSERT INTO md5_index VALUES(?, ?, ?): {}; {}; {}".format(md5_all, md5_list, filename))
self.db_conn.execute(
'''
INSERT INTO md5_index VALUES(?, ?, ?)
''', md5_all, md5_list, filename)
except:
pass
except Exception as e:
print e
logging.error("Error inserting a row")
raise FingerprintIndexWrite("Error inserting a row")
#
def __checkIntegrity(self):