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