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

Loading…
Cancel
Save