diff --git a/libs/fingerprint_index.py b/libs/fingerprint_index.py index 6dc741b..0903bf1 100644 --- a/libs/fingerprint_index.py +++ b/libs/fingerprint_index.py @@ -37,6 +37,8 @@ class FingerprintIndex: logging.info("No index file found, creating index now...") self.createIndex(fp_dir) self.db_conn = sql.connect(fq_fpidx) + + self.cur = self.db_conn.cursor() except: if self.db_conn: self.db_conn.close() @@ -64,20 +66,41 @@ class FingerprintIndex: logging.info("Successfully created index table") self.__populateIndex(fp_dir) logging.info("Successfully populated the index") - except Exception as e: - raise FingerprintIndexWrite("Error creating an index file\n{}".format(e)) + except Exception as ex: + raise FingerprintIndexWrite("Error creating an index file\n{}".format(ex)) finally: if self.db_conn: self.db_conn.close() self.db_conn = None +# +def qDatabaseMD5(self, md5_db): + try: + rows = self.cur.execute(''' + SELECT md5_list, fp_list, fp_count + FROM md5_all + WHERE md5_db=? + ''', [md5_db]) + except Exception as ex: + logging.error(ex) + +# +def qTableMD5(self, md5_table): + try: + rows = self.cur.execute(''' + SELECT fp_list, fp_count + FROM md5_tables + WHERE md5_table=? + ''', [md5_table]) + except Exception as ex: + logging.error(ex) + # def __populateIndex(self, fp_dir): """ read each file, pull md5, add row to database """ failCount = 0 finCount = 0 try: - self.cur = self.db_conn.cursor() db = FingerprintDB() files = os.listdir(fp_dir) for file in files: