diff --git a/find_duplicate_files/find_duplicate_files.py b/find_duplicate_files/find_duplicate_files.py index cdc528f..27b8254 100644 --- a/find_duplicate_files/find_duplicate_files.py +++ b/find_duplicate_files/find_duplicate_files.py @@ -60,7 +60,12 @@ class find_duplicate_files: def _check_file_cache(self, file): file_sql = file.replace("'", "\'") - result = self.cur.execute(f"SELECT hash FROM files WHERE file = '{file_sql}'") + query = f"SELECT hash FROM files WHERE file = '{file_sql}'" + try: + result = self.cur.execute(query) + except Exception as error: + self._log.error("Error executing query '{query}'. {error}") + sys.exit(2) row = result.fetchone() if row and len(row) > 0: return row[0] @@ -69,7 +74,12 @@ class find_duplicate_files: def _cache_file(self, file, hash): file_sql = file.replace("'", "\'") - result = self.cur.execute(f"INSERT INTO files (hash, file) VALUES ('{file_sql}', '{hash}')") + query = f"INSERT INTO files (hash, file) VALUES ('{file_sql}', '{hash}')" + try: + result = self.cur.execute(query) + except Exception as error: + self._log.error("Error executing query '{query}'. {error}") + sys.exit(3) self.cache_db.commit() return result