Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 27 |
Nodes: | 6 (0 / 6) |
Uptime: | 50:37:48 |
Calls: | 478 |
Calls today: | 10 |
Files: | 1,071 |
Messages: | 95,614 |
Posted today: | 1 |
On Tue, 10 Sep 2024 22:48:36 -0000 (UTC), Jon Ribbens wrote:
But what if you tell it the wrong thing ...
To get back to the original point of this thread, all that rigmarole to
try to ensure to call “rollback” in case of an exception is completely unnecessary: the DBMS will take care of that for you.
But what if you tell it the wrong thing ...
This is how I normally do things like this:
try:
do something .commit()
except:
log something .rollback()
Doing an explicit rollback ensures that the transaction is always rolled
back if it is interrupted for any reason.