From 04b5e1a7d354e149b4ea24c01c6101b696cd4506 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 1 Oct 2016 20:03:50 -0700 Subject: [PATCH] Remove extra DELETE FROM - Table has just been created, should alread by empty. --- advanced/Scripts/gravity_parse.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/advanced/Scripts/gravity_parse.py b/advanced/Scripts/gravity_parse.py index 529eb775..011a6bfd 100644 --- a/advanced/Scripts/gravity_parse.py +++ b/advanced/Scripts/gravity_parse.py @@ -71,19 +71,16 @@ counts = {'lc': 0} # Create the SQLite connection conn = sqlite3.connect('/etc/pihole/pihole.db') -conn.text_factory = str # I don't like it as a fix, but it works for now -c = conn.cursor() -create_tables() +with conn: + c = conn.cursor() -sql = "DELETE FROM gravity" -c.execute(sql) -conn.commit() + create_tables() -# Parse the log file. -for line in open(logfile): - line = line.rstrip() - counts['lc'] += 1 + # Parse the log file. + for line in open(logfile): + line = line.rstrip() + counts['lc'] += 1 if (counts['lc'] % 10000) == 0: conn.commit()