This commit is contained in:
Dan Schaper 2016-10-01 21:16:31 -07:00
parent e6873e0ebd
commit ae9b5bdffc

View file

@ -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 (?)"