I was wondering if there is a way to update all rows of a pandas dataframe in one query to mysql.
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.
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.
thanks
The error I get when trying to create the sql statement from the post Bob commented below.
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'}
<type 'exceptions.ValueError'>: zero length field name in format
args = ('zero length field name in format',)
message = 'zero length field name in format'