title: Writing Python Dataframe to MSSQL Table
body: <p>I currently have a Python dataframe that is 23 columns and 20,000 rows.  </p>
  
  <p>Using Python code, I want to write my data frame into a MSSQL server that I have the credentials for.  </p>
  
  <p>As a test I am able to successfully write some values into the table using the code below: </p>
  
  <pre><code>connection = pypyodbc.connect('Driver={SQL Server};' 
                                'Server=XXX;' 
                                'Database=XXX;' 
                                'uid=XXX;' 
                                'pwd=XXX')
  
  cursor = connection.cursor()
  
  for index, row in df_EVENT5_15.iterrows():
      cursor.execute("INSERT INTO MODREPORT(rowid, OPCODE, LOCATION, TRACKNAME)
  
  cursor.execute("INSERT INTO MODREPORT(rowid, location) VALUES (?,?)", (5, 'test'))
  connection.commit()
  </code></pre>
  
  <p>But how do I write all the rows in my data frame table to the MSSQL server?  In order to do so, I need to code up the following steps in my Python environment: </p>
  
  <blockquote>
    <ol>
    <li><p>Delete all the rows in the MSSQL server table</p></li>
    <li><p>Write my dataframe to the server</p></li>
    </ol>
  </blockquote>