title: Convert dictionary to a string and separate by coma each key-value pair
body: <p>I'm trying to write a simple function to update MySQL table from python dictionary:</p>
  
  <pre><code>data = {'foo':1, 'bar':2}
  table = 'mytable'
  pk = 'mypk'
  pk_value = 1
  
  sql = ''
  sql += 'UPDATE ' + table
  sql += 'SET ' + convert_dict_to_str(data)
  sql += 'WHERE ' + pk
  sql += ' = ' + pk_value
  sql += ';'
  
  
  def convert_dict_to_str(data):
      result = ''
      for key in data:
          result += "{key} = {value}".format(key=key, value=data[key])   
      return result
  
  print convert_dict_to_str(data)
  </code></pre>
  
  <p>But I got stuck on how to convert dict into <code>"key = value, key = value"</code>?
  In my example the desired output should be:</p>
  
  <pre><code> 'foo = 1, bar = 2'
  </code></pre>