DavidJB
DavidJB

Reputation: 2362

Update specific cell in mySQL using python

I've been using mySQLdb in python to import data into a database, however I would also like to be able to address a specific row and update a cell in that row, I couldn't find the command to do this in the mySQLdb help file, would anyone be kind enough to point me in the right direction...

Thanks,

Upvotes: 0

Views: 1144

Answers (1)

dm03514
dm03514

Reputation: 55962

You can use a sql UPDATE statement

psuedo data schema:

# table people
id INT, name VARCHAR(40), age INT, address VARCHAR(100)

1, john, 33, North America
2, dm03514, 28, Maryland

using pythong MySQLdb

cursor.execute('UPDATE people SET address = %s WHERE id = %s', ('Columbia, MD', 2));

Upvotes: 1

Related Questions