title: mysql update entire pandas dataframe
body: <p>I was wondering if there is a way to update all rows of a pandas dataframe in one query to mysql.</p>
  
  <p>I select a dataframe from mysql. Then I do some calculations and then I want the rows in the mysql table to update to the rows in the dataframe. I do not select the complete table so I cannot just replace the table. </p>
  
  <p>the column order/type remain unchanged so it just needs to replace/update the rows and I have a primary key indexed, auto-increment 'id' column if this makes any difference.</p>
  
  <p>thanks</p>
  
  <p>The error I get when trying to create the sql statement from the post Bob commented below.</p>
  
  <pre><code>58 d = {'col1': 'val1', 'col2': 'val2'} 
  59 sql = 'UPDATE table SET {}'.format(', '.join('{}=%s'.format(k) for k in d)) 
  60 print sql 
  61 sql undefined, k = 'col2', global d = {'col1': 'val1', 'col2': 'val2'} 
  &lt;type 'exceptions.ValueError'&gt;: zero length field name in format 
      args = ('zero length field name in format',) 
      message = 'zero length field name in format' 
  </code></pre>