Herwini
Herwini

Reputation: 447

How to update an entire sql column using python?

I want to update an entire column in a sql database. With the following command I can update a both the age and height of the person bob:

cursur.execute("UPDATE students SET age=10, height= 1.6 WHERE name='bob'")

But is there a way to fill in vectors for age, height and name, so that multiple values are updated simultaneously?

Upvotes: 0

Views: 151

Answers (1)

Rajan
Rajan

Reputation: 757

you can use a function:

def updateData(age, height, name):
    myQuery = "UPDATE students SET age=" + age + "  height=" + height +" WHERE name=" + name
    cursur.execute(myQuery)

you can use a for loop if you want to loop through array or any data.

Upvotes: 1

Related Questions