title: AttributeError:__exit__ on python 3.4
body: <p>Original Code:</p>
  
  <pre><code>import sys
  import os
  import latexmake
  
  import mysql.connector
  conn = mysql.connector.connect(user='root',password='oilwell',host='localhost',database='sqlpush1')
  
  with conn:
      mycursor = conn.cursor()
  mycursor=execute("SELECT DATE,oil,gas,oilprice,gasprice,totrev FROM results WHERE DATE BETWEEN '2011-01-01' AND '2027-12-01'")
  rows = mycursor.fetchall()
  a.write("\\documentclass{standalone}\\usepackage{booktabs}\n\n\\usepackage{siunitx}\r \n\
  \r\n\\begin{document}\r\n\\begin{tabular}{ccS[table-format = 5.2]} \\\\ \\toprule\r")
  a.write("Date &amp; Oil &amp; Gas &amp; Oil price &amp; Gas price &amp; Total Revenue \\\\ \\midrule \r")
  for row in rows:
      a = open("testtest.tex", "w")
      a.write("" + str(row[0]) + " &amp; " + str(row[1]) + " &amp; " + str(row[2]) + " &amp; " + str(row[3]) + " &amp; " + str(row[4]) + " &amp; " + str(row[5]) + " \\\\ \r")
  
      a.write("\\bottomrule \\end{tabular}\r\\end{document}")
      a.close
  print (os.path.getsize("testtest.tex"))
  os.system('latexmk.py -q testtest.tex')
  mycursor.close()
  conn.close()
  a.close()
  </code></pre>
  
  <p>After run by IDLE, and red error pop up like</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Users\Cheng XXXX\Desktop\tabletest.py", line 8, in &lt;module&gt;
      with conn:
  AttributeError: __exit__
  </code></pre>
  
  <p>I checked the file and cannot file mistake, need help. </p>