title: How to update mysql with python where fields and entries are from a dictionary?
body: <p>I am trying to create a re-usable mysql statement for updating from a dictionary where the keys are the database fields and the data to go into that field is the value associated with it in the dictionary.  This was easy when creating a function for inserting into mysql because it just involved two lists.  Now, I need to break apart the lists.  </p>
  
  <p>Here is what I have to work with.</p>
  
  <pre><code>fields = self.dictionary.keys()
  vals = self.dictionary.values()
  
  stmt = "UPDATE TABLE table_name SET %s = '%s'" %(.join(fields), .join(vals))"
  </code></pre>
  
  <p>This outputs a statement like:</p>
  
  <pre><code>UPDATE TABLE table_name SET column1, column2 = ('value1','value2')
  </code></pre>
  
  <p>I need it to output to standard format for updating a table like:</p>
  
  <pre><code>UPDATE table_name SET column1=value1, column2=value2
  </code></pre>