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
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'")
#row = cur.fetchone()
data = dict(zip(['value', 'timestamp'], row))
@ -205,9 +206,10 @@ while True:
# break
if new_forced_mode is not None:
data = Set_mode({"value": new_forced_mode})
db.session.add(data)
db.session.commit()
with app.app_context():
data = Set_mode({"value": new_forced_mode})
db.session.add(data)
db.session.commit()
#cursor.execute("INSERT OR REPLACE INTO set_mode (value) VALUES ('"+new_forced_mode+"')")
#dbconn.commit()
logging.info("Switch to "+new_forced_mode)