I have a MySQL database with 4 columns: X_coord
, Y_coord
, num_pos
, num_neg
What I want to do is update the num_pos corresponding to a specific location, stored in array called location where location[0]
is the X_coord
and location[1]
is the Y_coord
, and I want to do it dynamically like so:
sql = "UPDATE sentimentdata SET num_pos = num_pos + 1 WHERE X_coord = '%s' and Y_coord = '%s'" % (location[0],location[1])
My question is will this %s
formatting work?