Popular recipes by Carson Reynolds http://code.activestate.com/recipes/users/2680336/2005-11-26T18:28:53-08:00ActiveState Code RecipesGenerate SQL for insertation into table from dictionary object (Python)
2005-11-26T18:28:53-08:00Carson Reynoldshttp://code.activestate.com/recipes/users/2680336/http://code.activestate.com/recipes/457661-generate-sql-for-insertation-into-table-from-dicti/
<p style="color: grey">
Python
recipe 457661
by <a href="/recipes/users/2680336/">Carson Reynolds</a>
(<a href="/recipes/tags/database/">database</a>).
Revision 2.
</p>
<p>This recipe shows you how you might generate SQL code to insert the key-value pairs in a dictionary. The parameter table corresponds to an existing SQL table and dictionary keys correspond to the table's SQL column names. The SQL generated can then be inserted into a database (in this case MySQL) in the manner shown in exampleOfUse().</p>