我正在尝试创建一个函数来处理 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)
我无法确定导致此错误的原因。任何帮助,将不胜感激。谢谢你。
哆啦的时光机
相关分类