错误1064:您的SQL语法中有错误;使用python mysqldb

时间:2014-08-15 20:19:07

标签: python mysql

我有一张表格如下:

 CREATE TABLE IF NOT EXISTS `db`.`article` (
     `id` INT(11) NOT NULL AUTO_INCREMENT,
    `pid` VARCHAR(30) NOT NULL,
   `html` LONGTEXT NOT NULL,
    `text` LONGTEXT NOT NULL,
    `date` VARCHAR(50) NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE INDEX `url` (`url`)
)
ENGINE = InnoDB

我在python中使用mysqldb的插入操作是:

self.cursor.execute(\
            "insert into article ( pid ,date, html, text)\
            values (%s, %s, %s, %s)",
            ( item['pid'],item['pub_date'], item['body_html'], item['body_text'])
            )

当我包含body_text时,它会给我以下错误。没有body_text,它工作正常。 body_text是一个文本字段。

Error 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  '), 'Known as \\\"burneshas,\\\" this is a group of Albanian women who, for vario' at line 1

0 个答案:

没有答案