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
Post a Comment