heroku / salesforce-bulk

Python interface to the Salesforce.com Bulk API
MIT License
207 stars 154 forks source link

salesforce_bulk API when returns the data it converts the timestamp columns into bigint type #70

Closed shirkesonal closed 6 years ago

shirkesonal commented 6 years ago

Here is a sample code. If you notice the SystemModstamp & LastModifiedDate column values are converted into bigint from timestamp type. How can we preserve the original data type in the returned result?

from salesforce_bulk import SalesforceBulk

bulk = SalesforceBulk(username=“xxxxxx@xxxx.com", password=“xxxxxxxxx”,     security_token=“xxxxxxxxxxxxxxxxxxxxxx”)
# Create a new job
job = bulk.create_query_job("Contact", contentType='JSON')

# Add one or more batches to the job
batch = bulk.query(job, "select Id,LastName, LastModifiedDate,     SystemModstamp from Contact where SystemModstamp <  LAST_N_DAYS:20")

# Close the job
bulk.close_job(job)

# Wait for each batch to finish
while not bulk.is_batch_done(batch):
    time.sleep(10)

results = []
for result in bulk.get_all_results_for_query_batch(batch):
    results.append(json.load(IteratorBytesIO(result)))

for row in results:
    print(row)

Sample Output:

{'attributes': {'type': 'Contact', 'url':
'/services/data/v40.0/sobjects/Contact/0034400001sdfeIaAAI'}, 'Id':
'0034400001sdfeIaAAI', 'LastName': 'obrien', 'LastModifiedDate':
1539024446000, 'SystemModstamp': 1539024446000}