refactor redundant joins, bugfix event insert

This commit is contained in:
johnwang16
2024-10-19 21:24:51 -04:00
parent 9d1fccfe29
commit 400edd35d1
4 changed files with 7 additions and 10 deletions

View File

@@ -93,10 +93,7 @@ def save_scanned_devices (db):
# Proceed if variable contains valid MAC
if check_mac_or_internet(local_mac):
# Check if local mac has been detected with other methods
sql.execute (f"SELECT COUNT(*) FROM CurrentScan WHERE cur_MAC = '{local_mac}'")
if sql.fetchone()[0] == 0 :
sql.execute (f"""INSERT INTO CurrentScan (cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod) VALUES ( '{local_mac}', '{local_ip}', Null, 'local_MAC') """)
sql.execute (f"""INSERT OR IGNORE INTO CurrentScan (cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod) VALUES ( '{local_mac}', '{local_ip}', Null, 'local_MAC') """)
#-------------------------------------------------------------------------------
def print_scan_stats(db):
@@ -769,4 +766,4 @@ def guess_type(vendor, mac, ip, name, default):
result = "Router"
return result