0
鉴于这一部分功能(和Python 2.7,MySQL的连接器2.1.6):为什么cursor.with_rows返回`True`,但fetch_one返回`None`?
def get_target_item(self, query, key):
self._target_query.execute(query, (key,))
if self._target_query.with_rows:
raw_item = self._target_query.fetchone()
我预期raw_item始终是非None
,但事实证明,有时None
。
如果我补充一点:
if not raw_item:
print "Could not find find target item for query {0} and key {1}".format(query, key)
我可以看到这个被印有时。如果我自己运行相同的查询,我可以看到查询不返回指定键的行。那么为什么with_rows
表明它呢?