\######最主要的是插入语句错误

1. 字段内容问题,比如 : “古堡\公主“他们“这样“那样 ” 等

其中包含了 双引号,以及反斜杠等字符,pymsql插入sql语句中如果是: sql = ' “Null,"%s","%s" ' 就会出现插入错误

解决办法: conn.escape\_string(str(category)) 会把内容自动转义成可接受字符串


2.插入表问题,比如

  sql = 'insert into rank VALUES (NULL ,"%s","%s","%s","%s","%s","%s","%s" ,"%s","%s","%s","%s" ,"%s","%s","%s","%s" ,"%s","%s","%s","%s","%s")'<br></br><br></br>  cur.execute(sql % (info_id, count, title, str(category),author,description<br></br>                   ,rank_title,vertical_image_url,status,update_status,update_day,comics_count,<br></br>                    comments_count,likes_count,fav_count,view_count,popularity_value,is_free,date,c))<br></br><br></br><br></br>    其中本机跑没问题,但是转移电脑后,就插入不进去---------<br></br>  <br></br><strong>  解决办法:    </strong>sql = 'insert into <strong style="font-size: 15px;">数据库名.rank</strong> VALUES (NULL ,"%s",........'
  
<br></br>会持续更新....2019.8.8

标签: count, mysql, 插入, sql, category, into, rank, pymsql, 偏门

相关文章推荐

添加新评论,含*的栏目为必填