I update the variable directly in the database (manually). But, the code in the while
loop never updates the variable because it is in a loop, I would like to know what I should do to get the new value.
Maybe exit the loop and reopen it? I tried with break
, but it closes the script.
import sqlite3
def read_data(data, table):
con = sqlite3.connect("settings.db")
cur = con.cursor()
read_data.row = cur.execute(f"SELECT {data} FROM {table}").fetchall()[0][0]
read_data("data", "eyes")
eyes = read_data.row
while True:
read_data("data", "eyes")
eyes_loop = read_data.row
if eyes_loop != eyes:
print("Eyes changed")
break
else:
print("Eyes not changed")
continue