赞
踩
解决:pymysql.err.OperationalError: (1054, “Unknown column ‘None’ in ‘where clause’”)
下面是我代码中的sql语句
"SELECT
question_id,
question_type
FROM
lms_question
WHERE
company_id ={}
AND is_deleted = 0;".format (self.company_id)
运行后报错 : pymysql.err.OperationalError: (1054, “Unknown column ‘None’ in ‘where clause’”)
E pymysql.err.OperationalError: (1054, "Unknown column 'None' in 'where clause'")
||||||||||||||||||||
|||||||||||||||
||||||||||
|||||
|||
让其运行成功,转成字符串即可,加单引或双引
:company_id 等于的 “{}”加上单引号
"SELECT
question_id,
question_type
FROM
lms_question
WHERE
company_id = '{}'
AND is_deleted = 0;".format (self.company_id)
:company_id 等于的 “%s”加上单引号或者双引号
"SELECT
question_id,
question_type
FROM
lms_question
WHERE
company_id = '%s'
AND is_deleted = 0;" % self.company_id
:company_id 等于的“{self.company_id}”加上单引号或者双引号
"SELECT
question_id,
question_type
FROM
lms_question
WHERE
company_id = '{self.company_id}'
AND is_deleted = 0;"
以上的解决方法其实原理都是一样的,无非就是几种字符串的格式化操作罢了,随便复习了下python字符串的格式化操作!
小小总结可能会解决你的问题,也可能解决不了你的问题,但还是希望对您有所帮助,感谢阅读,如有疑义,欢迎来扰!未完待续…
一直都在努力变好中,希望您也是,加油!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。