search

Home  >  Q&A  >  body text

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 days ago686

reply all(1)I'll reply

  • 天蓬老师

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

    It means conn.total_changes is an int. Just result = conn.total_changes, don’t add ()

    reply
    0
  • Cancelreply