Browse Source

module name conflict

master
rscmbbng 6 years ago
parent
commit
ca30b15ca7
  1. 9
      slog.py

9
slog.py

@ -4,7 +4,7 @@ import sqlite3
now = datetime.datetime.now()
day = now.strftime('%F')
time = now.strftime('%H:%M')
the_time = now.strftime('%H:%M')
url = 'https://solar.lowtechmagazine.com/api/stats.json'
@ -13,7 +13,6 @@ if not os.path.exists('stats.db'):
c = db.cursor()
c.execute("""CREATE TABLE stats(date text, time text, error text, server text)
""")
db.commit()
else:
db = sqlite3.connect('stats.db')
c = db.cursor()
@ -36,7 +35,6 @@ except URLError as e:
data = None
pass
else:
# everything is fine
data = response.read().decode('utf-8')
@ -44,9 +42,12 @@ else:
if error:
error = error.args[1]
time.sleep(1)
c.execute("""INSERT INTO stats VALUES(?,?,?,?)""", (day, time, error, data))
c.execute("""INSERT INTO stats VALUES(?,?,?,?)""", (day, the_time, error, data))
time.sleep(1)
db.commit()
time.sleep(1)
db.close()

Loading…
Cancel
Save