title: INSERT Pandas Dataframe to SQL-Server using Python - Jupyter Notebook
body: <p>Till now, I've been requesting data from my SQL-server, using an API, <code>php</code> file basically and using the <code>requests</code> module in Python. So here's my code for that:</p>
  
  <pre><code># importing the requests library
  import requests
  
  # api-endpoint
  URL = "https://******.co.in/******/queryRandom.php"
  
  # location given here
  token= '***************'
  
  query= 'SELECT userId,createdAt,.... FROM xyz WHERE date &gt;= CURDATE() - INTERVAL 60 DAY'
  
  # defining a params dict for the parameters to be sent to the API
  PARAMS = {'token':token, 'query':query}
  
  # sending get request and saving the response as response object
  r = requests.post(url = URL, data = PARAMS)
  df=pd.DataFrame(r.json())
  df.head()
  </code></pre>
  
  <p>Now after I'm done with my work, I formed a dataframe like this:</p>
  
  <pre><code>Sl.No.  date    nameofthepic    
  1   26-08-2018  10-must-see-waterfalls-in-karnataka-8081714182d8    
  2   26-08-2018  a-month-in-backpack-one-girl-one-goal-to-explore-the-himalayas-22813ee67e15 
  3   26-08-2018  a-month-in-backpack-one-girl-one-goal-to-explore-the-himalayas-week-1-8d113ee673db  
  4   26-08-2018  a-month-in-backpack-one-girl-one-goal-to-explore-the-himalayas-week-1-22b13ee67b87  
  5   26-08-2018  backpacking-for-a-month-in-the-himalayas-week-1-30813ee674a6
  </code></pre>
  
  <p>Now using the similar <code>requests</code> module, is there a way I can write something like this: <code>INSERT INTO table_name...</code> and upload the dataframe into the SQL table. </p>
  
  <p>The main problem I'm not able to figure out is:</p>
  
  <p>i) How do I upload the dataframe column values into the table in one go? </p>
  
  <p>ii) If its not possible through requests module, is there any other way I can upload the Pandas dataframe values into SQL-server table directly from <code>jupyter-notebook</code> using Python code?  </p>