Python Mysql Fetch返回参数问题

当python查询mysql并返回值为null时,cursor.fetchone或fetchall的传参会报一下错误
TypeError: bind() takes exactly one argument (2 given)

sqlcmd = "select rowwhichisnull from tableA"
cur.execute(sqlcmd)
rowResult=cur.fetchone()[0]

当if 条件判断sql返回为Null,如果使用了

if rowResult == 'NULL' || rowResult == ''

则就会报开头的TypeError
if判断可设置为:

if rowResult is None:
   print("Row Result is None")
else:
   print('Not None')
posted @ 2021-04-05 22:54  dereklok  阅读(253)  评论(0)    收藏  举报