python连接Mysql错误:_mysql_exceptions.OperationalError: (1054, "Unknown column 'CVE' in 'field lis解决办法

_mysql_exceptions.OperationalError: (1054, "Unknown column 'CVE' in 'field list'")

(1)错误:#1054 - Unknown column 'CVE' in 'field list'

python连接Mysql错误:_mysql_exceptions.OperationalError: (1054,

 

primaryTable_info_insert = "INSERT INTO primaryTable (cve_id, iie_id, publishedDate, lastModifiedDate) VALUES (%s, %s, %s, %s);" % (cve_id, iie_id, publishedDate, lastModifiedDate)

解决办法:后面的内容虽然是字符串,但是仍然需要加单引号,或者双引号。如我在后面的'%s'上加上了单引号。然后问题就解决了。

primaryTable_info_insert = "INSERT INTO primaryTable (cve_id, iie_id, publishedDate, lastModifiedDate) VALUES ('%s', '%s', '%s', '%s');" % (cve_id, iie_id, publishedDate, lastModifiedDate)
INSERT INTO table_name ( field1, field2,...fieldN )
                       VALUES
                       ( value1, value2,...valueN );

正确参考实例如下:

mysql> INSERT INTO runoob_tbl
    -> (runoob_title, runoob_author, submission_date)
    -> VALUES ("JAVA 教程", "RUNOOB.COM", '2016-05-06');

你可能感兴趣的:(mysql数据库)