title: Speeding (Bulk) Insert into MySQL with Python
body: <p>I'm deploying an application to consume some .csv data. I want to copy them to a MySQL table. With some help from the stackoverflow users I wrote the code bellow:</p>
  <pre><code>import csv
  import MySQLdb
  
  db = MySQLdb.connect(   host = &quot;dbname.description.host.com&quot;,
                          user = &quot;user&quot;,
                          passwd = &quot;key&quot;,
                          db = &quot;dbname&quot;)
  cursor = db.cursor()
  
  query = 'INSERT INTO table_name(column,column_1,column_2,column_3)
  VALUES(%s, %s, %s, %s)'                                                         
  
  csv_data = csv.reader(file('file_name'))
  
  for row in csv_data:
       cursor.execute(query,row)
       db.commit()
  
  cursor.close()
  </code></pre>
  <p>The problem is, currently, the process is so slow and I need to speed the things up.</p>