title: Connect to mysql with python and upload csv
body: <p>I am new to python.I want to connect to mysql using the mysql.connector with python.After i want to open a csv and then upload it to mysql database.I am using python version : 3.6.0</p>
  
  <p>I have tried this one:</p>
  
  <pre><code>import csv
  import mysql.connector
  
  cnx = mysql.connector.connect(user='', password='',
                                host='127.0.0.1',
                                database='')
  csv_data = csv.reader(file('12_13.csv'))
  for row in csv_data:
  
      cursor.execute('INSERT INTO testcsv(names, \
            classes, mark )' \
            'VALUES("%s", "%s", "%s")',
            row)
  #close the connection to the database.
  mydb.commit()
  cursor.close()
  print("Done")
  </code></pre>
  
  <p>I am getting this error:</p>
  
  <blockquote>
    <p>Traceback (most recent call last):   File ".\uploadtomysql.py", line
    7, in 
        csv_data = csv.reader(file('12_13.csv')) NameError: name 'file' is not defined</p>
  </blockquote>
  
  <p>Thanks!</p>