代码:
sql = "insert into dm_copy(演出类型,演出场馆,剧目名称,演出地点,演出时间,演出票价,演出团体,创建时间, url)values('%s','%s','%s','%s','%s','%s','%s','%s','%s')" % (category, venue, name, city, showtim, prices[:-1], actor, Creation_time, p_url)
问题是:
pymysql.err.ProgrammingError: (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 'tWe','2018/07/09 09:33','https://piao.damai.cn/155901.html')' at line 1")
原因可能是actor值
有引号
解决方式
pymysql.escape_string()
代码:
sql = "insert into dm_copy(演出类型,演出场馆,剧目名称,演出地点,演出时间,演出票价,演出团体,创建时间, url)values('%s','%s','%s','%s','%s','%s','%s','%s','%s')" % (category, venue, name, city, showtim, prices[:-1], pymysql.escape_string(actor), Creation_time, p_url)