title: Is connection.commit() needed after each cursor.execute()?
body: <p>Is it a valid PyMySQL operation to <code>cursor.execute(…)</code> multiple times before executing <code>connection.commit()</code>, or does <code>connection.commit()</code> need to occur after each execute statement for the results to be stored properly? The idea is to eliminate as many redundant statements as possible, as the process is long-running.</p>
  
  <p>Code structure:</p>
  
  <pre><code>with connection.cursor() as cursor:
      …
      cursor.execute(SQLtype1, rowToInsert)
  
      cursor.execute(SQLtype2, otherToInsert)
  
      connection.commit() # does this account for both execute statements, or just the last?
  </code></pre>
  
  <p>I’ve reviewed the following:</p>
  
  <p><a href="http://pymysql.readthedocs.io/en/latest/user/examples.html" rel="noreferrer">PyMySQL execute/commit example</a>, but with only one example having only one execute statement.</p>
  
  <p><a href="https://stackoverflow.com/questions/5669878/when-to-close-cursors-using-mysqldb/42965024#42965024">Python MySQLdb example</a>, but with an example showing a commit after each execute statement</p>
  
  <p><a href="https://stackoverflow.com/questions/28401124/connection-commit-performance-impact">Python SQLite example</a>, shows multiple execute statements before a commit, but it's uncertain whether SQLite handles differently</p>
  
  <p><strong>Note:</strong> As the SQL queries are different, <code>executemany</code> doesn’t appear to be an option.</p>