I wrote a MediaMonkey extension based on a much older iTunes script that was, and is, written in Python.
Because of that historical glitch, I do some things oddly, such as accessing the MM database directly.
So, now I'm trying to adapt things to the MM COM API as much as possible. My first step, I assumed, would be to replace all my direct use of sqlite3 with win32com and mm.Database calls. (If all goes well, I hope to eventually not require the user to install Python.)
Most everything looks like it should work; but the big exception is a couple of transactions I use. They have failure paths (usually triggered by user aborts), and I do a rollback if anything unpleasant happens.
But although MM documents BeginTransaction and Commit, it doesn't seem to have anything like a Rollback. Is there some reason for this? Will I no longer be able to rollback in case of error?
-Wm
Is it possible to Rollback a transaction?
Moderators: Gurus, Addon Administrators
-
- Posts: 31
- Joined: Fri Dec 11, 2009 9:40 am
Re: Is it possible to Rollback a transaction?
I didn't find any Rollback either. My code in my plugin typically looks like this in C# based on examples I found. I didn't know if they had some way of realizing that if you didn't call commit they have auto rollback in their code?
Code: Select all
try {
MediaMonkey.Database.BeginTransaction();
track.Rating = rating;
track.UpdateDB();
} finally {
MediaMonkey.Database.Commit();
}
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
MonkeyTunes - DACP Server for MediaMonkey
Intelliremote - Take Back Control of your HTPC!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
MonkeyTunes - DACP Server for MediaMonkey
Intelliremote - Take Back Control of your HTPC!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-
- Posts: 31
- Joined: Fri Dec 11, 2009 9:40 am
Re: Is it possible to Rollback a transaction?
My best guess was that rollback might be impossible due to too many threads running... But I don't know. Perhaps the lack of rollback is left over from their use of Access before they switched to SQLite.
Anyhow, I should be able to mostly avoid corruption, I hope.
-Wm
Anyhow, I should be able to mostly avoid corruption, I hope.
-Wm