问题描述
我关注了其他与在Postgresql中插入字典有关的帖子。语法如下:
<button id="btn">Update score</button>
<button id="score">Show score</button>
该词典包含以下数据:
sql_insert = 'INSERT INTO table_results (id,name,state,response,duration_time) VALUES (%(id)s,%(name)s,%(response)s,%(duration_time)s);'
然后,我可以执行插入语句:
data= {'id': 29,'name': "ABC'S KINDERGARDEN",'response': 'OK','duration_time': 60}
db.session.execute(sql_insert,data_dict )
我已经尝试了几种方法来将此作为最普遍接受的格式。
(psycopg2.errors.SyntaxError) Syntax error at or near "%"
LINE 1: ...1,result_response,result_duration_secs) VALUES (%(id)s,%(...
^
[sql: INSERT INTO table_results (id,duration_time) VALUES (%%(id)s,%%(name)s,%%(state)s,%%(response)s,%%(duration_time)s);]
(Background on this error at: http://sqlalche.me/e/13/f405)
谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)