con = lite.connect('test.db')
with con:
cur = con.cursor()
for key in merged_dict:
print str(key) + ": " + str(merged_dict[key])
cur.execute("INSERT OR REPLACE INTO Games (Url, '" + str(key) + "'), VALUES ('" +merged_dict['Url'] + "', '" + str(merged_dict[key]) + "')")
给出了这个错误:
Traceback (most recent call last):
File "/home/benjamin/Documents/insertTest.py", line 7, in <module>
cur.execute("INSERT OR REPLACE INTO Games (Url, '" + str(key) + "'), VALUES ('" +merged_dict['Url'] + "', '" + str(merged_dict[key]) + "')")
OperationalError: near ",": syntax error
我也尝试打印出查询而不是执行它们。这是一个示例:
INSERT OR REPLACE INTO Games (Url, 'h1_home'), VALUES ('ILP9hhls', '0')
这是非法的查询吗?
答案 0 :(得分:1)
在VALUES之前不应该有逗号,即:
INSERT OR REPLACE INTO Games (Url, 'h1_home') VALUES ('ILP9hhls', '0')
以下是供参考的示例查询: