title: After execute connection.commit(), why the others cursor.execute() not work correctly?
body: <p>I was using PyMysql lib to add some lines to my database, I got a very long list of SQL, maybe more than 150000 rows. So I thought to execute commit my every 5000 times, the code is here:</p>
  
  <pre><code>import pymysql
  
  sql_list = ["sql1", "sql2", "sql3", ...]  # Very long list, more than 150000 rows
  conn = pymysql.connect(
      host="localhost",
      port=3306,
      user="user",
      password="abc-123",
      database="test",
      charset="utf8"
  )
  cursor = conn.cursor()
  
  flag = 0  # flag, for the count
  for sql in sql_list:
      cursor.execute(sql)
      flag += 1
      if flag &gt; 5000:
          conn.commit()
          flag = 0
  
  </code></pre>
  
  <p>When I tried to run this script, I got some rows in my database, but not the full.<br>
  Then I have changed the code to this:</p>
  
  <pre><code>import pymysql
  
  sql_list = ["sql1", "sql2", "sql3", ...]  # Very long list, more than 150000 rows
  conn = pymysql.connect(
      host="localhost",
      port=3306,
      user="user",
      password="abc-123",
      database="test",
      charset="utf8"
  )
  cursor = conn.cursor()
  
  # flag = 0  # flag, for the count
  for sql in sql_list:
      cursor.execute(sql)
      # flag += 1
      # if flag &gt; 5000:
      #     conn.commit()
      #     flag = 0
  conn.commit()
  </code></pre>
  
  <p>It works correctly! Why? Is my consideration redundant?<br>
  Any suggestion will be appreciate.</p>