def build_sf_dict(): # Connect to SalesForce using my credentials while True: try: sf = Connection(username=sfuser, password=sfpassword, security_token=sftoken) report = sf.get_report(sfreport) print "Connection to SalesForce was successful, report opened successfully." parser = salesforce_reporting.ReportParser(report) # Return a dictionary of the Open Engineering Escalations Report dictionary = parser.records_dict() return dictionary break except: print "Connect to SalesForce was unsuccessful, trying to connect again." break
def build_sf_dict(self): # Connect to SalesForce using my credentials while True: try: sf = Connection(username=sfuser, password=sfpassword, security_token=sftoken) report = sf.get_report(sfreport) print "Connection to SalesForce was successful, report opened successfully." parser = salesforce_reporting.ReportParser(report) # Return a dictionary of the Open Engineering Escalations Report dictionary = parser.records_dict() return dictionary break except: print "Connect to SalesForce was unsuccessful, trying to connect again." print("Unexpected error:", sys.exc_info()[0]) break
#!/usr/bin/env python # -*- coding: utf-8 -*- import csv from salesforce_reporting import Connection import salesforce_reporting import os sf = Connection(username='******',password='******', security_token="4fNUFqwEbGVP3NUiJo2Un33PY") report = sf.get_report('00O1N0000091uFSUAY',details=True) print(dir(sf.get_report)) parser = salesforce_reporting.ReportParser(report) #print(parser._get_field_labels()) lines = parser.records() #for i in items: # print (i reportCsvFile = csv.writer(open(os.path.join(os.path.dirname(__file__), 'AndromacoContenido.csv'), 'a', encoding='UTF-8')) reportCsvFile.writerows(lines)