title: Write query rows in csv python
body: <p>I'm wrinting a script to write query results rows in a csv file. The data is email adresses, like this :</p>
  
  <blockquote>
    <p>email1@mail.com</p>
    
    <p>email2@mail.com</p>
    
    <p>email3@mail.com</p>
  </blockquote>
  
  <p>For now, my code writes my results in the csv file like this :</p>
  
  <blockquote>
    <p>('email1@mail.com'), ('email2@mail.com'), ('email3@mail.com'),</p>
  </blockquote>
  
  <p>How can I use next lines instead of rows ?</p>
  
  <p><strong>EDIT :</strong> It seems that my query gives me data between brackets like ('email1@mail.com'),</p>
  
  <p>Here is the code :</p>
  
  <pre><code>import pymysql
  import csv
  
  db = pymysql.connect(host="localhost", port=3306, user="foo", passwd="bar", db="db")
  cursor = db.cursor()
  
  query3 = """SELECT email FROM tmp"""
  
  
  cursor.execute(query)
  
  data = cursor.fetchall()
  list = []
  
  for row in data :
    value = str(row)
    list.append(value)    
    file = open('file.csv', 'wb')
    data = csv.writer(file)
    data.writerow(list)
  
  cursor.close()
  db.close()
  file.close()
  </code></pre>