首页 > 数据库技术 > 详细

Python Mysql Fetch返回参数问题

时间:2021-04-06 09:09:42      阅读:29      评论:0      收藏:0      [点我收藏+]

当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‘)

Python Mysql Fetch返回参数问题

原文:https://www.cnblogs.com/lokliao/p/14619866.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!