在python中有一个错误:mysqldb语法错误

2024-04-25 20:59:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一张桌子如下:

 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的insert操作是:

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'])
            )

当我包含正文时,它会给我以下错误。没有正文就可以了。 正文文本是一个文本字段。你知道吗

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

Tags: text文本idurldatehtmlarticlenot