(1)
delete from student;
(2)在python里面写mysql的语句是,千万千万要留意单引号!!!报错为:
MySQL check the manual that corresponds to your MySQL server version for the right syntax错误
这个错误的意思是,你的mysql语句写错啦,快去检查一下啊
首先,如果table是参数,分开写!!!
sql_update = "update %s"%table
其次,如果用%的话,必须在%s加上单引号变为 ‘%s’,等价于execute里面的逗号,逗号会自动加入单引号,一下为%的格式
sql_update = sql_update+" set image='%s' where url='%s'"% (str(item['image']), item['url'])
tx.execute(sql_update)
喏,这就是逗号的格式
tx.execute(sql_update+" set image=%s where url=%s", (str(item['image']), item['url']))
tx.execute(sql_update+
" set image_urls=%s where url=%s"
,
(
str
(item[
'image_urls'
])
,
item[
'url'
]))