Continue Flask migration.

This commit is contained in:
yohan 2024-06-02 10:51:25 +02:00
parent fd2266aaf5
commit 69c791e7ca

View File

@ -118,7 +118,8 @@ def get_metric(metric, current_time, interval):
return None return None
def get_forced_mode(): def get_forced_mode():
row = db.session.query(Set_mode.value, Set_mode.timestamp).first() with app.app_context():
row = db.session.query(Set_mode.value, Set_mode.timestamp).first()
#cur.execute("SELECT value, timestamp FROM set_mode WHERE name='mode'") #cur.execute("SELECT value, timestamp FROM set_mode WHERE name='mode'")
#row = cur.fetchone() #row = cur.fetchone()
data = dict(zip(['value', 'timestamp'], row)) data = dict(zip(['value', 'timestamp'], row))
@ -205,9 +206,10 @@ while True:
# break # break
if new_forced_mode is not None: if new_forced_mode is not None:
data = Set_mode({"value": new_forced_mode}) with app.app_context():
db.session.add(data) data = Set_mode({"value": new_forced_mode})
db.session.commit() db.session.add(data)
db.session.commit()
#cursor.execute("INSERT OR REPLACE INTO set_mode (value) VALUES ('"+new_forced_mode+"')") #cursor.execute("INSERT OR REPLACE INTO set_mode (value) VALUES ('"+new_forced_mode+"')")
#dbconn.commit() #dbconn.commit()
logging.info("Switch to "+new_forced_mode) logging.info("Switch to "+new_forced_mode)