def rollback_savepoint(self):
try:
self.db.execute("rollback to savepoint pt;")
except:
print "roll back to save point failed"
else:
print "Roll back to save point. Done"
在上面的代碼片段中,它說「回退到保存點失敗」。 出了什麼問題?python sqlite 3:回滾保存點失敗
編輯: 我改變了代碼如下圖所示,收到錯誤消息
self.db.execute("savepoint pt;")
print "Save point created"
self.cursor.execute("insert into STK values(33)")
self.db.execute("rollback to savepoint pt;")
錯誤
Save point created
Traceback (most recent call last):
File "open_db.py", line 77, in <module>
obj1.save_point()
File "open_db.py", line 63, in save_point
self.db.execute("rollback to savepoint pt;")
sqlite3.OperationalError: no such savepoint: pt
什麼是例外? – 2010-02-02 08:18:54
永遠不會捕獲你沒有處理的異常。讓它升起,這樣你可以得到有用的錯誤信息和回溯。 – nosklo 2010-02-02 08:42:47