Efficient way to build a MySQL update query in Python
Posted
by ensnare
on Stack Overflow
See other posts from Stack Overflow
or by ensnare
Published on 2010-04-30T16:52:10Z
Indexed on
2010/04/30
16:57 UTC
Read the original article
Hit count: 196
I have a class variable called attributes which lists the instance variables I want to update in a database:
attributes = ['id', 'first_name', 'last_name', 'name', 'name_url',
'email', 'password', 'password_salt', 'picture_id']
Each of the class attributes are updated upon instantiation.
I would like to loop through each of the attributes and build a MySQL update query in the form of:
UPDATE members SET id = self._id, first_name = self._first name ...
Thanks.
© Stack Overflow or respective owner