title: Update table in sql server, with values in pandas dataframe
body: <p>i have a table in sql server</p>
  
  <pre><code>id    count
  1       1
  2       1
  3       1
  4       1
  5       1
  </code></pre>
  
  <p>i have another table in pandas dataframe(df), with updated count</p>
  
  <pre><code>id    count
  1       1
  2       1
  3       2
  4       3
  5       4
  </code></pre>
  
  <p>i want to make changes in my database using Update query, and i am thinking to define a function, which would do this.</p>
  
  <p>i am using pypyodbc for my connection.</p>
  
  <pre><code>    conn = pypyodbc.connect("Driver={SQL Server};Server=&lt;YourServer&gt;;Database=&lt;YourDatabase&gt;;uid=&lt;YourUserName&gt;;pwd=&lt;YourPassword&gt;"
  </code></pre>
  
  <p>i tried using</p>
  
  <pre><code>for row in df.iterrows():
      updateQuery = "update "+db_table+" set count="+str(row[1][1])+" where id= '"+str(row[1][0])+"'"
      cursor.execute(updateQuery)
      conn.commit()
  </code></pre>
  
  <p>But is there any better way of doing this?</p>