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)
有人可以说为什么这个问题被拒绝投票吗?这阻止了我提出进一步的问题。 –