0
我正在嘗試更新或修改來自Flask Python的SQLite數據庫特定單元中的現有數據。但我無法更新。此外,我也沒有收到任何錯誤。同時,我可以在表格的新行中插入新數據。爲什麼我無法從Python更新SQLite數據庫中的數據?
服務器端代碼:
@app.route("/")
@app.route("/<state>")
def get_post_javascript_data(state=None):
connection = sqlite3.connect('/home/pi/toggle7.db')
cursor = connection.cursor()
load = 'light5'
status = 'ON'
if state == 'Load1on':
sock.send('Load1ON')
print ("sent: Load1ON")
try:
cursor.execute("UPDATE user1 SET load = 'light5' WHERE id='1'")
connection.commit()
message = "success"
except:
connection.rollback()
message = "failure"
finally:
connection.close()
print (message)
有人可以說爲什麼這個問題被拒絕投票嗎?這阻止了我提出進一步的問題。 –