我正在尝试创建一个函数来处理API错误消息,但是我在python中得到了这个错误消息:
Exception has occurred: sqlite3.OperationalError
near "Test4": syntax error
服务器响应为:
{"message":"Failed to validate one or more request parameters","validationErrors":["Budget name must be unique. 'Test4 - X4574747-PHONE' already exits"]}
我的代码是:
def error():
if "message" in r.json():
logText = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()) + " : " + r.json()['message']
c.execute("INSERT INTO log VALUES ('"+ logText +"')")
conn.commit()
if "validationErrors" in r.json():
logText = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()) + " : " + r.json()['validationErrors'][0]
c.execute("INSERT INTO log VALUES ('"+ logText +"')")
conn.commit()
os._exit(1)
我不知道是什么导致了这个错误。任何帮助都将不胜感激。谢谢您。