pymysql 写sql报的错误和动态语句的写法

TypeError: %d format: a number is required, not str

要传入一个数字而不是字符串

pymysql.err.InternalError: (1054, "Champ '被修改了ya' inconnu dans where clause")

要传入的是字符串

sql语句的两种写法:

第一种是使用占位符{0},format传入占位符的值

"select * from art where title='{0}' and id={1}".format('被修改了ya','2')))

第二种:
"select * from art where id=%s and title='%s'"%(1,'被修改了ya')))



posted @ 2017-03-04 15:46  bigvase  阅读(1550)  评论(0编辑  收藏  举报