搜索

首页  >  问答  >  正文

python - 使用sqllite的conn.total_changes()问题

版本3.5

def Exec(self, sql, param=None):
        conn = sqlite3.connect(self.path)
        try:
            if param is None:
                conn.execute(sql)
            else:
                conn.execute(sql, param)
            conn.commit()
        except Exception as err:
            print(err)
        finally:
            result = conn.total_changes()
            conn.close()
        return result

sql 是 insert into Config values(null,'aaa','aaa','2017-03-30',0)
然后
result = conn.total_changes()
位置报错
'int' object is not callable

黄舟黄舟2786 天前685

全部回复(1)我来回复

  • 天蓬老师

    天蓬老师2017-04-18 10:32:05

    意思就是conn.total_changes是个int。result = conn.total_changes 就行,不要加()

    回复
    0
  • 取消回复