def _write_mysql(frame, table, names, cur):
    bracketed_names = [('`' + column + '`') for column in names]
col_names = ','.join(bracketed_names)
wildcards = ','.join(['%s'] * len(names))
insert_query = 'INSERT INTO %s (%s) VALUES (%s)' % (table, col_names, wildcards
    )
data = [[(None if type(y) == float and np.isnan(y) else y) for y in x] for
    x in frame.values]
cur.executemany(insert_query, data)
Python Pandas write to sql with NaN values