From: Roland Häder Date: Mon, 22 May 2023 15:08:57 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9a92130f9edccc159b4abea899002213c6062fea;p=fba.git Continued: - reduce amount of rows to one (performance) --- diff --git a/fba.py b/fba.py index 67638c3..7f5f74d 100644 --- a/fba.py +++ b/fba.py @@ -51,7 +51,7 @@ def get_hash(domain: str) -> str: def update_last_blocked(domain: str): # NOISY-DEBUG: print("DEBUG: Updating last_blocked for domain", domain) try: - cursor.execute("UPDATE instances SET last_blocked = ?, last_updated = ? WHERE domain = ?", [ + cursor.execute("UPDATE instances SET last_blocked = ?, last_updated = ? WHERE domain = ? LIMIT 1", [ time.time(), time.time(), domain @@ -72,13 +72,13 @@ def update_last_error(domain: str, res: any): res = str(res) if type(res) is str: - cursor.execute("UPDATE instances SET last_status_code = 999, last_error_details = ?, last_updated = ? WHERE domain = ?", [ + cursor.execute("UPDATE instances SET last_status_code = 999, last_error_details = ?, last_updated = ? WHERE domain = ? LIMIT 1", [ res, time.time(), domain ]) else: - cursor.execute("UPDATE instances SET last_status_code = ?, last_error_details = ?, last_updated = ? WHERE domain = ?", [ + cursor.execute("UPDATE instances SET last_status_code = ?, last_error_details = ?, last_updated = ? WHERE domain = ? LIMIT 1", [ res.status_code, res.reason, time.time(), @@ -96,7 +96,7 @@ def update_last_error(domain: str, res: any): def update_last_nodeinfo(domain: str): # NOISY-DEBUG: print("DEBUG: Updating last_nodeinfo for domain:", domain) try: - cursor.execute("UPDATE instances SET last_nodeinfo = ?, last_updated = ? WHERE domain = ?", [ + cursor.execute("UPDATE instances SET last_nodeinfo = ?, last_updated = ? WHERE domain = ? LIMIT 1", [ time.time(), time.time(), domain diff --git a/fetch_blocks.py b/fetch_blocks.py index b8cab86..ab9849f 100644 --- a/fetch_blocks.py +++ b/fetch_blocks.py @@ -74,7 +74,7 @@ for blocker, software in fba.cursor.fetchall(): # NOISY-DEBUG: print("DEBUG: Looking up instance by domain:", blocked) fba.cursor.execute( - "SELECT domain FROM instances WHERE domain = ?", [blocked] + "SELECT domain FROM instances WHERE domain = ? LIMIT 1", [blocked] ) if fba.cursor.fetchone() == None: @@ -226,7 +226,7 @@ for blocker, software in fba.cursor.fetchall(): elif blocked.count("*") < 1: # No obsfucation for this instance fba.cursor.execute( - "SELECT hash FROM instances WHERE domain = ?", [blocked] + "SELECT hash FROM instances WHERE domain = ? LIMIT 1", [blocked] ) if fba.cursor.fetchone() == None: @@ -322,7 +322,7 @@ for blocker, software in fba.cursor.fetchall(): # NOISY-DEBUG: print("DEBUG: AFTER-blocked:", blocked) fba.cursor.execute( - "SELECT domain FROM instances WHERE domain = ?", [blocked] + "SELECT domain FROM instances WHERE domain = ? LIMIT 1", [blocked] ) if fba.cursor.fetchone() == None: @@ -384,7 +384,7 @@ for blocker, software in fba.cursor.fetchall(): blocked = searchres[0] fba.cursor.execute( - "SELECT domain FROM instances WHERE domain = ?", [blocked] + "SELECT domain FROM instances WHERE domain = ? LIMIT 1", [blocked] ) if fba.cursor.fetchone() == None: