First thing first, code is list below,
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 & Oil & Gas & Oil price & Gas price & Total Revenue \\\\ \\midrule \r")
for row in rows:
a = open("testtest.tex", "w")
a.write("" + str(row[0]) + " & " + str(row[1]) + " & " + str(row[2]) + " & " + str(row[3]) + " & " + str(row[4]) + " & " + 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()
after run IDLE, an error called "Invalid Syntax" pop up on line "os.path.getsize"
I did import os at very beginning, and I don't know why.
Appreciated your kind help.
Regards,
Cheng
It's not the
os.path.getsize
that's the problem, it's theprint
. You're using Python 3 andprint
is now a function, and therefore needs parentheses.Also, it'd be nice (though admittedly, you'd never notice in this script) if you actually called
close
rather than just referencing it: