Efficient way to build a MySQL update query in Python
- by ensnare
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.