python-'int' object is not callable
- UID
- 1066743
|
python-'int' object is not callable
情况
使用pymsql进行数量查询,报错’int’ object is not callable。
原因–可能性一使用变量名与方法内置变量名冲突
参考
原因–可能性二 属性值当作方法使用
def count_t_quality_by_id_name(id, name):
sql_str = ("SELECT * "
+ " FROM t_quality"
+ " WHERE id='%s' and name='%s'" % (id, name))
con = connect_quality_db()
cur = con.cursor()
cur.execute(sql_str)
rows = cur.rowcount()
logger.info("%s %s 在质检表中数量为 %i" % (id, name,rows) )
cur.close()
con.close()
return rows
解决方案
def count_t_quality_by_id_name(id, name):
sql_str = ("SELECT * "
+ " FROM t_quality"
+ " WHERE id='%s' and name='%s'" % (id, name))
con = connect_quality_db()
cur = con.cursor()
cur.execute(sql_str)
rows = cur.rowcount
logger.info("%s %s 在质检表中数量为 %i" % (id, name,rows) )
cur.close()
con.close()
return rows |
|
|
|
|
|