code: def upsert_records(conn, records, upsert_statement):
      
  
      with conn:
          with conn.cursor() as cursor:
              for record in records:
                  cursor.execute(upsert_statement, record)
docs: Upsert records.