commit to the DB more frequently

This commit is contained in:
Lynne Megido 2018-11-17 15:16:28 +10:00
parent ab43960e61
commit 3de328299a
Signed by: lynnesbian
GPG key ID: FB7B970303ACE499
2 changed files with 2 additions and 1 deletions

1
run.py
View file

@ -59,6 +59,7 @@ for row in dc.fetchall():
if tbc > int(cfg['max_time_between_checks']): if tbc > int(cfg['max_time_between_checks']):
tbc = cfg['max_time_between_checks'] tbc = cfg['max_time_between_checks']
c.execute("UPDATE data SET last_check = %s, time_between_checks = %s", (t, tbc)) c.execute("UPDATE data SET last_check = %s, time_between_checks = %s", (t, tbc))
db.commit()
db.commit() db.commit()

2
web.py
View file

@ -176,7 +176,7 @@ def do_login():
pw_hashed = hashlib.sha256(pw_in.encode('utf-8')).digest() pw_hashed = hashlib.sha256(pw_in.encode('utf-8')).digest()
acct = request.form['acct'] acct = request.form['acct']
session['username'] = re.match("^@([^@]+)@", acct).group(1) session['username'] = re.match("^@([^@]+)@", acct).group(1)
session['instance'] = "https://{}".format(re.search("@([^@]+)$", acct).group(1)) session['instance'] = "https://{}".format(re.search("@([^@]+)$", acct).group(1)) #todo: this occasionally gets "https://@username@instan.ce"
dc.execute("SELECT * FROM data WHERE username = %s AND instance = %s", (session['username'], session['instance'])) dc.execute("SELECT * FROM data WHERE username = %s AND instance = %s", (session['username'], session['instance']))
data = dc.fetchone() data = dc.fetchone()
db.close() db.close()