热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

scrapy采集入为库mysql数据库,只更新一个字段提示这个语法错误?

就是查询有没有这个字,如果查到这个字就更新这个字的bsmc字段表是news_topic插入代码如下:

就是查询有没有这个字,如果查到这个字就更新这个字的 bsmc 字段
表是 news_topic
插入代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
    def insert_into_info(self, conn, item):

        print ('starts...')

        ziinfo = item['zi']

        conn.execute("""select 1 from news_topic where zi = %s""", (ziinfo, ))

        ret = conn.fetchone()

        tp_id = int(conn.lastrowid)

        print ('###aa')

        if ret:

            print(u'开始更新这条数据')

            UPDATE news_topic SET bsmc = item['bsmc'] WHERE id = tp_id;

            pass

        else:

            pass

提示如下图错误

不知道 mysql 更新 语句是不是有问题?

谢谢

aa 加引号


推荐阅读
author-avatar
烧蕉_233
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有