当我执行查询以插入到db中时,我使用pymysql创建一个小程序来连接到mysql数据库:
self.cur.execute("INSERT INTO test(table1, table2) VALUES (%s, s%)", ('values1','values2'))
查询执行完美,但我尝试插入像这样的字典
self.cur.execute("INSERT INTO test(%s) VALUES (%s)" % (",".join(dict.keys(), ",".join(dict.values()))))
我有这个错误
pymysql.err.ProgrammingError:(1064,"您的SQL语法中有错误;请查看与您的MariaDB服务器版本对应的手册,以便在#39:// www附近使用正确的语法.url.com'在第1行")
我试着写这样的
self.cur.execute("INSERT INTO test(%s) VALUES (%s)", (",".join(dict.keys()), ",".join(dict.values())))
但现在我有这个错误
pymysql.err.InternalError:(1054," Unknown column' values1' in' field list'")