我第一次遇到两个实例
n=("""INSERT INTO table_name (name,other) values(%s,%s)""")
cur.execute(n,(c1,c3,))
这很完美,但在哪里
n=("""INSERT INTO %s (name,other) values(%s,%s)""")
cur.execute(n,(table_name,c1,c3,))
这无法插入值
表名作为用户的输入
这是我得到的错误
pymysql.err.ProgrammingError: (1064, "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 ''elon_musk' (name,other) values('Elon Musk','Musk in 2015')' at line 1")