Is it possible to Rollback a transaction?

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey.

Moderator: Gurus

Is it possible to Rollback a transaction?

Postby wtanksleyjr » Fri Jul 06, 2012 4:41 pm

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
wtanksleyjr
 
Posts: 21
Joined: Fri Dec 11, 2009 9:40 am

Re: Is it possible to Rollback a transaction?

Postby Melloware » Sat Jul 07, 2012 7:28 am

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
 
Posts: 329
Joined: Mon Aug 18, 2008 9:46 am
Location: Philadelphia, PA, US

Re: Is it possible to Rollback a transaction?

Postby wtanksleyjr » Sat Jul 07, 2012 7:23 pm

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
wtanksleyjr
 
Posts: 21
Joined: Fri Dec 11, 2009 9:40 am


Return to Addons developer forum

Who is online

Users browsing this forum: No registered users and 3 guests