Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. def insertFromDict(table, dict):
  2. """Take dictionary object dict and produce sql for
  3. inserting it into the named table"""
  4. sql = 'INSERT INTO ' + table
  5. sql += ' ('
  6. sql += ', '.join(dict)
  7. sql += ') VALUES ('
  8. sql += ', '.join(map(dictValuePad, dict))
  9. sql += ');'
  10. return sql
  11.  
  12. def dictValuePad(key):
  13. return '%(' + str(key) + ')s'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement