From ae9b5bdffc41bdf2648829316641472a72a5120f Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 1 Oct 2016 21:16:31 -0700 Subject: [PATCH] Comments --- advanced/Scripts/gravity_parse.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/advanced/Scripts/gravity_parse.py b/advanced/Scripts/gravity_parse.py index 29d50be6..42446f4e 100644 --- a/advanced/Scripts/gravity_parse.py +++ b/advanced/Scripts/gravity_parse.py @@ -43,16 +43,20 @@ import sqlite3 +# Logfile containing unique list of all domains on downloaded lists. logfile = '/etc/pihole/pihole.2.eventHorizon.txt' # Create the SQLite connection conn = sqlite3.connect('/etc/pihole/pihole.db') +# Python auto-handle commits, no need to call for commits manually with conn: c = conn.cursor() + # Lists have just been downloaded, clear out the existing data c.execute('DROP TABLE IF EXISTS gravity') + # Ready new table for list of domains qt = ''' CREATE TABLE IF NOT EXISTS gravity ( idx INTEGER PRIMARY KEY ASC, @@ -64,7 +68,7 @@ with conn: # enable WAL mode c.execute('PRAGMA journal_mode=WAL;') - # Parse the log file. + # Parse the log file into the database with open(logfile) as f: for line in f: sql = "INSERT INTO gravity (domain) VALUES (?)"