Created
October 14, 2021 19:18
-
-
Save meanother/583cdd7eaa3e6cc2cbb960bd3aed0bf5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def insert_on_conflict(table: str, array: List, sql: str) -> None: | |
item = array[0] | |
columns = ', '.join(item.keys()) | |
dd = ["%s" for _ in range(len(item.keys()))] | |
placeholders = ", ".join(dd) | |
row = sql.format(table, columns, placeholders) | |
cursor.executemany(row, [tuple(item.values()) for item in array]) | |
conn.commit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment