title: Speed up insertion of pandas dataframe using fast_executemany Python pyodbc
body: <p>I am trying to insert data contained in a .csv file from my pc to a remote server. The values are inserted in a table that contains 3 columns, namely <code>Timestamp</code>, <code>Value</code> and <code>TimeseriesID</code>. I have to insert approximately 3000 rows at a time, therefore I am currently using <code>pyodbc</code> and <code>executemany</code>. </p>
  
  <p>My code up to now is the one shown below:</p>
  
  <pre><code>with contextlib.closing(pyodbc.connect(connection_string, autocommit=True)) as conn:
      with contextlib.closing(conn.cursor()) as cursor:
          cursor.fast_executemany = True  # new in pyodbc 4.0.19
  
              # Innsert values in the DataTable table
              insert_df = df[["Time (UTC)", column]]
              insert_df["id"] = timeseriesID
              insert_df = insert_df[["id", "Time (UTC)", column]]
              sql = "INSERT INTO %s (%s, %s, %s)  VALUES (?, ?, ?)" % (
                  sqltbl_datatable, 'TimeseriesId', 'DateTime', 'Value')
  
              params = [i.tolist() for i in insert_df.values]
              cursor.executemany(sql, params)
  </code></pre>
  
  <p>As I am using <code>pyodbc 4.0.19</code>, I have the option <code>fast_executemany</code> set to <code>True</code>, which is supposed to speed up things. However, for some reason, I do not see any great improvement when I enable the fast_executemany option. Is there any alternative way that I could use in order to speed up insertion of my file?</p>
  
  <p>Moreover, regarding the performance of the code shown above, I noticed that when disabling the <code>autocommit=True</code> option, and instead I included the <code>cursor.commit()</code> command in the end of my data was imported significantly faster. Is there any specific reason why this happens that I am not aware of?</p>
  
  <p>Any help would be greatly appreciated :)</p>