mysql查询更新,但删除Python中的记录

时间:2019-01-15 11:36:31

标签: python mysql database

我想用db中的Python更新记录。但是命令已删除记录。

display: grid

结果:

sql_select_Query = """SELECT id from fuel where imei = '%i' and 
date_format(start_time, '%%Y-%%m-%%d') = date_format(now(), '%%Y-%%m-%%d') and 
isnull(finish_time)""" % (int(lokasyon[2]))

cursor = con.cursor()
cursor.execute(sql_select_Query)
records = cursor.fetchone()

cur.execute("UPDATE fuel set finish_time= '%s', 
kapanis_enlem= '%f', kapanis_boylam= '%f' where id = '%i' " % (date_fin, 
float(liste[3][1:]),float(liste[4][2:]),int(records[0])))

con.commit()
print(cur.rowcount, "record(s) affected")             
       except MySQLdb.Error, e:
            print "Error %d: %s" % (e.args[0],e.args[1])
            sys.exit(1)  

但是记录已删除。我在做什么错了?

0 个答案:

没有答案