MOD: insert is working, but there is already collisions for the md5 of the entire schema and the field was marked as unique. I will investigate if this accurate.

This commit is contained in:
JohnE 2015-12-11 02:24:40 -08:00
parent 5e6fc05b81
commit 246cb522da
1 changed files with 7 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import sys
import logging import logging
import sqlite3 as sql import sqlite3 as sql
from libs.exceptions import FingerprintIndexWrite from libs.exceptions import FingerprintIndexWrite
from libs.exceptions import FingerprintIndexOpen
from libs.fingerprint import FingerprintDB from libs.fingerprint import FingerprintDB
# prefixed with "_" so that it will be listed first and visible # prefixed with "_" so that it will be listed first and visible
@ -67,6 +68,8 @@ class FingerprintIndex:
""" read each file, pull md5, add row to database """ """ read each file, pull md5, add row to database """
failCount = 0 failCount = 0
finCount = 0 finCount = 0
# self.db_conn.execute("INSERT INTO md5_index VALUES(?, ?, ?)", ["AAA", "BBB", "CCC"])
# self.db_conn.execute("INSERT INTO md5_index VALUES('DDD', 'EEE', 'FFF')")
try: try:
db = FingerprintDB() db = FingerprintDB()
files = os.listdir(fp_dir) files = os.listdir(fp_dir)
@ -80,22 +83,23 @@ class FingerprintIndex:
# print("db_hash=={}".format(db.db_hash)) # print("db_hash=={}".format(db.db_hash))
# print("table_hashes={}".format(db.table_hashes)) # print("table_hashes={}".format(db.table_hashes))
#md5_all = __createMD5Index(dbht) #md5_all = __createMD5Index(dbht)
return
finCount = finCount+1 finCount = finCount+1
except: except:
failCount = failCount+1 failCount = failCount+1
except: except:
pass pass
finally:
self.db_conn.commit()
logging.info("Completed populating the index. Completed: {} Failed: {} ".format(str(finCount), str(failCount))) logging.info("Completed populating the index. Completed: {} Failed: {} ".format(str(finCount), str(failCount)))
# #
def __insertRecord(self, md5_all, md5_list, filename): def __insertRecord(self, md5_all, md5_list, filename):
try: try:
logging.info("INSERT INTO md5_index VALUES(?, ?, ?): {}; {}; {}".format(md5_all, str(md5_list), filename)) # logging.info("INSERT INTO md5_index VALUES(?, ?, ?): {}; {}; {}".format(md5_all, str(md5_list), filename))
self.db_conn.execute( self.db_conn.execute(
''' '''
INSERT INTO md5_index VALUES(?, ?, ?) INSERT INTO md5_index VALUES(?, ?, ?)
''', (md5_all, str(md5_list), filename)) ''', [md5_all, ','.join(md5_list), filename])
except Exception as e: except Exception as e:
logging.error("Error inserting a row\n{}".format(e)) logging.error("Error inserting a row\n{}".format(e))
raise FingerprintIndexWrite("Error inserting a row") raise FingerprintIndexWrite("Error inserting a row")