I'm trying to learn about python-mysql connector, and things have been going well, until I bumped into this little problem. The 3rd line in the snippet below is giving me the following error:
mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''employee' NATURAL JOIN department' at line 1
con = connector.connect(user='root',host='127.0.0.1',passwd='***',database='sqltest')
crs = con.cursor()
crs.execute("SELECT * FROM %s NATURAL JOIN department",("employee",))
result = crs.fetchall()
self.t1.setRowCount(len(result)+1)
self.t1.setColumnCount(len(result[0]))
self.t1.setItem(0,0,QTableWidgetItem("ID"))
When I replaced the statement without dynamic query, i.e SELECT * FROM employee NATURAL JOIN department
, things seem to work just fine.
Hoping that somebody knows a way around this snag. Thanks!