Set correct db in gravity_parse. Start using with in dnsmasq

This commit is contained in:
Dan Schaper 2016-10-02 11:26:40 -07:00
parent 185efaf82e
commit 14424939a9
2 changed files with 14 additions and 13 deletions

View file

@ -147,6 +147,8 @@ logfile = sys.argv[1]
# Create the SQLite connection # Create the SQLite connection
conn = sqlite3.connect('/etc/pihole/pihole.db') conn = sqlite3.connect('/etc/pihole/pihole.db')
with conn:
c = conn.cursor() c = conn.cursor()
create_tables() create_tables()
@ -164,4 +166,3 @@ for line in open(logfile):
elif (': reply ' in line) or (': cached ' in line): elif (': reply ' in line) or (': cached ' in line):
parse_reply(line) parse_reply(line)
conn.commit()

View file

@ -18,7 +18,7 @@ import sqlite3
logfile = '/etc/pihole/pihole.2.eventHorizon.txt' logfile = '/etc/pihole/pihole.2.eventHorizon.txt'
# Create the SQLite connection # Create the SQLite connection
conn = sqlite3.connect('/etc/pihole/gravity.db') conn = sqlite3.connect('/etc/pihole/pihole.db')
# Python auto-handle commits, no need to call for commits manually # Python auto-handle commits, no need to call for commits manually
with conn: with conn: