May-11-2020, 06:26 PM
Greetings,
I am very new to Python and am looking for help to get a json document inserted into SQL so I can parse it. This will be an ongoing process that I'm hoping to do with SSIS. I've managed to get the content I want (from Survey Monkey API) using the following code. This is run within SQL Server SSMS and puts the data I want in the Surveys_Json variable. I need to get this outputted to an SQL Server database. I know SQL much more than I know Python. Once I get the document into SQL, I can parse it using the Json functions there. Any help would be appreciated.
EXECUTE sp_execute_external_script
@language = N'Python'
, @Script = N'
import requests
import json
client = requests.session()
headers = {
"Authorization": "bearer %s" % "apikey",
"Content-Type": "application/json"
}
data = {}
HOST = "https://api.surveymonkey.net"
SURVEY_LIST_ENDPOINT = "/v3/surveys/"
uri = "%s%s" % (HOST, SURVEY_LIST_ENDPOINT)
surveylist = client.get(uri, headers=headers)
surveys_json = surveylist.json()
print(surveys_json)
'
I am very new to Python and am looking for help to get a json document inserted into SQL so I can parse it. This will be an ongoing process that I'm hoping to do with SSIS. I've managed to get the content I want (from Survey Monkey API) using the following code. This is run within SQL Server SSMS and puts the data I want in the Surveys_Json variable. I need to get this outputted to an SQL Server database. I know SQL much more than I know Python. Once I get the document into SQL, I can parse it using the Json functions there. Any help would be appreciated.
EXECUTE sp_execute_external_script
@language = N'Python'
, @Script = N'
import requests
import json
client = requests.session()
headers = {
"Authorization": "bearer %s" % "apikey",
"Content-Type": "application/json"
}
data = {}
HOST = "https://api.surveymonkey.net"
SURVEY_LIST_ENDPOINT = "/v3/surveys/"
uri = "%s%s" % (HOST, SURVEY_LIST_ENDPOINT)
surveylist = client.get(uri, headers=headers)
surveys_json = surveylist.json()
print(surveys_json)
'