title: How to stream result with mysql.connector
body: <p>I'm pretty rusty with sql and python since uni days.</p>
  
  <p>I wonder how to read line by line of the query result instead of fetchall?</p>
  
  <p>here are my current test code:</p>
  
  <pre><code>#!/usr/bin/python
  import time
  import csv
  import mysql.connector
  
  start_time = time.time()
  cnx = mysql.connector.connect(user='user', password='1234',
                                host='10.0.10.100',
                                database='serverDB')
  
  try:
   cursor = cnx.cursor()   
   cursor.execute("select * from serverDB.task")
   result = cursor.fetchall()
   with open("query.csv", "wb") as csv_file:
      csv_writer = csv.writer(csv_file)
      csv_writer.writerow([i[0] for i in cursor.description]) # write headers
      csv_writer.writerows(result)
  
   for x, row in enumerate(result):
    print x
    print row
    #print result
  finally:
   cnx.close()
   print "there are ", numrows, "rows"
   print("--- %s seconds ---" % (time.time() - start_time))
  </code></pre>