Insert into MySQL with Python dict

How to use Python dict as data source for MySQL insert-into statement.

placeholders = ', '.join(['%s'] * len(dict_data))
columns = ', '.join(dict_data.keys())
sql = "INSERT INTO %s ( %s ) VALUES ( %s )" % (table, columns, placeholders)
cursor.execute(sql, dict_data.values())

See also this stackoverflow for reference

mysql python database