execute sql command in python -


when run code in raspberry-pi nothing happend , code runs smouthly there no results

#!/usr/bin/python import mysqldb  db = mysqldb.connect(host="localhost", # host, localhost                  user="root", # username                   passwd="raspberry", # password                   db="raspberry") # name of data base   cur = db.cursor()    cur.execute("update visitors set nb_visits = nb_visits+1 id = 1") 

you should commit transaction before changes take effect :

cur.execute("update visitors set nb_visits = nb_visits+1 id = 1") db.commit() 

Comments

Popular posts from this blog

android - How to save instance state of selected radiobutton on menu -

python 3 IndexError: list index out of range -

IF statement in MySQL trigger -