Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. def bulk_insert_copyfrom(cursor, table_name, field_names, values):
  2. if not values: return
  3.  
  4. #print "bulk copy from prepare..."
  5.  
  6. str_vals = "n".join("t".join(adapt_to_str(val) for val in cur_vals) for cur_vals in values)
  7. strf = StringIO(str_vals)
  8. #print "bulk copy from execute..."
  9. cursor.copy_from(strf, table_name, columns=tuple(field_names))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement