title: What happens when multiple threads are writing to a single table in mysql?
body: <p>I am facing a situation where multiple threads are trying to insert data to the same table in mysql, **Will it be OK without explicit handle it? ** I am afraid every thread is inserting, some thread will be locked and hold on too long, then cause the program to corrupt.  </p>
  
  <p>Basically I am trying to do is the following:</p>
  
  <pre><code>import threading
  import mysql.connector
  
  db = mysql.connector.connect()
  cursor = db.cursor()
  
  
  def update_to_table(data):
      sql = "insert into my_db.my_table values(%s)" % data
      cursor.excute(sql)
      db.commit()
      print("update complete!")
  
  
  for i in range(10):
      print("%d -th time..." % i)
      data = get_data(i)
      t = threading.Thread(target=update_to_table, args=(data,))
      t.start()
  </code></pre>
  
  <p>Do I need to check if other threads are inserting, and hold on and waiting until them to finish etc... </p>
  
  <p>The data for different i has no overlap so we don't need to worry about the duplicate key problem.</p>
  
  <p><strong>After experimenting, it seems some thread will hang on and no response.</strong></p>