Commit c6a571aa authored by Your Name's avatar Your Name

bug fix

parent 695259ff
...@@ -213,8 +213,10 @@ def update_or_insert(df2,queue_name): ...@@ -213,8 +213,10 @@ def update_or_insert(df2,queue_name):
cur = con.cursor() cur = con.cursor()
try: try:
for i in range(0, device_count): for i in range(0, device_count):
query = "INSERT INTO esmm_device_diary_queue_test (device_id, city_id, time,%s) VALUES(%s, %s, %s, %s) ON DUPLICATE KEY UPDATE device_id=%s, city_id=%s, time=%s, %s=%s" query = """INSERT INTO esmm_device_diary_queue_test (device_id, city_id, time,%s) VALUES(%s, %s, %s, %s) \
cur.execute(query, (queue_name, df2.device_id[i], df2.city_id[i], df2.time[i], df2[queue_name][i], df2.device_id[i], df2.city_id[i], df2.time[i], queue_name, df2[queue_name][i])) ON DUPLICATE KEY UPDATE device_id=%s, city_id=%s, time=%s, %s=%s""" % (queue_name, df2.device_id[i],df2.city_id[i], df2.time[i], df2[queue_name][i], df2.device_id[i], df2.city_id[i], df2.time[i], queue_name, df2[queue_name][i])
print(query)
cur.execute(query)
con.commit() con.commit()
con.close() con.close()
print("insert or update sucess") print("insert or update sucess")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment