Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
from mysql.connector import Error
from datetime import datetime
query_result= [{'End_Date__c': datetime.date(2018, 7, 20), 'User_Email__c': '
[email protected]
', 'ProductVersion__c': '1', 'Product_Name__c': 'Payor', 'itil_b__Account__r': {'type': 'Account', 'Id': '', 'Customer_Short_Name__c': 'TESTACCT'}, 'Target_Environment__r': {'type': 'Environment__c', 'Id': '', 'Name': 'TEST-PROD'}, 'type': 'itil_b__Fulfillment__c', 'Id': 'a3sc0000000CiZpAAK'}, {'End_Date__c': datetime.date(2018, 7, 19), 'User_Email__c': '
[email protected]
', 'ProductVersion__c': '4', 'Product_Name__c': 'CareManager', 'itil_b__Account__r': {'type': 'Account', 'Id': '', 'Customer_Short_Name__c': 'TESTACCT'}, 'Target_Environment__r': {'type': 'Environment__c', 'Id': '', 'Name': 'TEST-NONPROD'}, 'type': 'itil_b__Fulfillment__c', 'Id': 'a3sc0000000CiAyAAK'}]
record=query_result['records']
df=pd.DataFrame(records)
print df
When I execute above python script, I am getting error
Traceback (most recent call last):
File "test.py", line 10, in <module>
query_result= [{'End_Date__c': datetime.date(2018, 7, 20), 'User_Email__c': '[email protected]', 'ProductVersion__c': '1', 'Product_Name__c': 'Payor', 'itil_b__Account__r': {'type': 'Account', 'Id': '', 'Customer_Short_Name__c': 'TESTACCT'}, 'Target_Environment__r': {'type': 'Environment__c', 'Id': '', 'Name': 'TEST-PROD'}, 'type': 'itil_b__Fulfillment__c', 'Id': 'a3sc0000000CiZpAAK'}, {'End_Date__c':datetime.date(2018, 7, 19), 'User_Email__c': '[email protected]', 'ProductVersion__c': '4', 'Product_Name__c': 'CareManager','itil_b__Account__r': {'type': 'Account', 'Id': '', 'Customer_Short_Name__c': 'TESTACCT'}, 'Target_Environment__r': {'type': 'Environment__c', 'Id': '', 'Name': 'TEST-NONPROD'}, 'type': 'itil_b__Fulfillment__c', 'Id': 'a3sc0000000CiAyAAK'}]
TypeError: descriptor 'date' requires a 'datetime.datetime' object but received a 'int'
The input I am passing to query_result got from a salesforce soap Api.
Please help me to resolve this issue..
Thanks in advance
As when you say from datetime import datetime
you are just importing one method and that and not the whole module. And you haven't imported the date
method.
You could also do this:
>>> from datetime import date
>>> date(2018, 9, 20)
datetime.date(2018, 9, 20)
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.