Python MySQL update statement does not work -
i try perform simple update statement in python 2.7 won't work @ all. hope can show me mistake:
import mysqldb import datetime db = mysqldb.connect(host="localhost", # host, localhost user="root", # username passwd="", # password db="******") # name of data base cur = db.cursor() cur.execute("select * data") row in cur.fetchall(): id_row = str(row[0]) date = str(row[1]) new_date = date[:-2] new_date += "00" cur.execute("update data set date={0} id={1}".format(new_date, id_row)) db.close()
the script should take date unix timestamp database cut off last 2 numbers, replace them 00 , update row in database. code replace numbers works update process not. show no error message , exits code 0.
i have no idea made mistake. can help?
thanks lot!
shame on me!
the error missing db.commit().
thank hints! :)
Comments
Post a Comment