当我使用这个条款时,一切都是对的。find
这里是モンキー・D・ルフィ
sql_fmt = "select name, gender, age, height, hobby, ability, popularity, voice_actor, birth_place, image from characters where name in ('%s');" % find.encode('utf-8')
self.db.execute(sql_fmt)
但当我使用这个子句时,出现了错误。find
在这里是(モンキー・D・ルフィ)
或('モンキー・D・ルフィ')
sql_fmt = "select name, gender, age, height, hobby, ability, popularity, voice_actor, birth_place, image from characters where name in %s;"
self.db.execute(sql_fmt, find)
错误:
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 ''(\'\xe3\x83\xa2\xe3\x83\xb3\xe3\x82\xad\xe3\x83\xbc\xe3\x83\xbbD\xe3\x83\xbb\xe3\x83\xab\xe3\x83\x95\xe3\x82\xa3\')'' at line 1") And for this clause, error happened.
find
here isモンキー・D・ルフィ
.
sql_fmt = "select name, gender, age, height, hobby, ability, popularity, voice_actor, birth_place, image from characters where name in ('%s');"
self.db.execute(sql_fmt, find)
对于这个条款,一切都很顺利。find
这里是モンキー・D・ルフィ
。你知道吗
sql_fmt = "select name, gender, age, height, hobby, ability, popularity, voice_actor, birth_place, image from characters where name in (%s);"
self.db.execute(sql_fmt, find)
注意:
我使用in
表示它是一组字符串,而不仅仅是一个字符串。你知道吗
查询中可能缺少“”
或者可能是这样的,我不用。你知道吗
您应该使用:
相关问题 更多 >
编程相关推荐