有谁可以告诉我为什么这不会返回任何结果?我正在尝试将数据从JSON
列复制到新列中,将这些结果乘以 10%,然后在10%增加的人口旁边显示原始人口。
Python似乎运行它,但没有返回结果。
try:
query = ("UPDATE city SET Population = info->'$.Population' WHERE info->'$.Population' > 0")
cursor.execute(query)
conn.commit()
except Exception as ex:
print("cursor execution failure: " + str(ex))
query = ("SET Population = Population * 1.1")
cursor.execute(query)
conn.commit()
except Exception as ex:
print("cursor execution failure: " + str(ex))
query = ("SELECT Name, info->’$.Population’, Population FROM city;")
cursor.execute(query)
except Exception as ex:
print("cursor execution failure: " + str(ex))
for row in cursor:
print(u"{:<45} {:<45}".format(*row))
答案 0 :(得分:0)
SET的SQL语法为false,您必须替换:
query = ("SET Population = Population * 1.1")
通过
query = ("UPDATE city SET Population = Population * 1.1")