Skip to content

Python Insert to SQL Server #21496

Answered by Djin1050
Djin1050 asked this question in General
Discussion options

You must be logged in to vote

Found somehting that worked. I’m posting the entire thing in case any newbie like me needs help to pull data from a REST API and  get it into SQL as this took me awhile to get it going

import requests
import pyodbc
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)

response = client.get(uri, headers=headers)

response_json = response.json()

conn = pyodbc.connect(‘Driver={SQL Server};’
‘Server=Servername;’
‘Database=DatabaseName;’
‘Trusted_Connection=yes;’)

cursor = conn.cursor()
curso…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant