The project in which I wrote a python script to process rows in an Excel spreadsheet interfacing with a MySQLdb and fronted on the web end using django is coming to a close. There is just one more requirement to go. They want rollback capabilities with the ability to completely rollback all actions on a particular excel file if one of the rows in the file buffs up or errors out. This is so that they can correct just that one row in that Excel file then feed the same Excel file to my Python process script without worry about the sanctity of the data of the rest of the rows.
This means that I have to somehow implement a multi-row rollback functionality or application level transaction. Python's MySQLdb library supports rollback but only on each transaction. I need a "all or nothing" like functionality. This is something new for me, so I scouted around on google to get some inspiration or to see if someone else had done the same thing. I found this small transaction class by Harald Hoyer at his site. Planning to try out his stuff to see if they can fulfill my requirements. Instinctively, I feel the final solution that I come up with will be a bit different.
The only other way I can see this happening is to maintain another database table keeping track of all actions that are performed at the row level in the input Excel Forms eg: row1 : insert, row2: update. Then if the script detects an error or Exception while processing the form it will perform the reciprocal or rollback to all of the actions that have been performed on the data on the Excel file. So far whatever I have is still being worked out in the noggin' coming close to being implemented.
Update:
Something that I seem to have overlooked is that since I am using django for the web front maybe I can also use it's ORM at the backend. It all depends on how much work it would be to ORM-ize my existing code base.
Monday, January 26, 2009
Friday, January 23, 2009
Lenovo's ideapad
Today I was tasked by the better half to bring a lenovo ideapad S10 to life. My date with the ideapad got off to a rough start when during the initial filling in of the customary username and password and other stuff, the power died on me. From there on the puppy was not too happy with me and refused to boot up slapping me in the face with a "Installation not complete" dialog box and proceeded to reboot every time I clicked on the 'Ok' button or tried to cancel it. Good stuff. Tried the reboot-click-on-dialog cycle for about 3 to 4 times before calling yer-olde' friendly tech support dude who began the conversation with "Don't mean to be offensive..." (I mean what was I supposed to do?! It doesn't even come with a damned rescue disk!) Ever notice how people always tend to start getting nasty every time after saying that.... ?! Yeehawe!
Okay, so after a little bit of good vibes rescue generally telling how manly he sounded on the horn, the guy tells me that there is a rescue button there that can reset the baby back to it's factory settings ... Ah! So that is what that little non-standard button is fer! The funny thing about this button is that it will only work if the unit is turned off! Tried it during boot up and no way Jose! The button was like non responsive, just like when you tell your gf _not_ to go MNG just this once for your date. It only worked after I finally hunkered down to read the damn manual! Now, why didn't I just save myself the aggravation and did that from the beginning? Why? I don't know, I just want to be cool like everyone?!
At this point the lappie is working fine installed with a printer and a hax0red version of office 2007. Hey! don't be barking down this pair of pants asking why not openoffice! When the customer is your gf and she ain't in the mood of hearing about your FSS evangelism, you shut up and and nod man! The customer is always right, doubly so when she is your better half!
On the performance of this little guy I can only say this ... "It's slow and steady". Stuff works but there is just that little bit of lag before starting up, hey give it a break it's just that little atom of a processor under the hood man! I am quite happy with the performance considering that we only forked out Rm 1,783 with printer thrown in! I can see the appeal this kind of lappie would have for the ever on the go exec that just wants to occasionally check his/her mail or do the usual proposal on the run. For the rest of us that needs that performance juice from their daily machine, and do more than that stay clear!
Well, at least it's been fun and I am still in her good books :)
Okay, so after a little bit of good vibes rescue generally telling how manly he sounded on the horn, the guy tells me that there is a rescue button there that can reset the baby back to it's factory settings ... Ah! So that is what that little non-standard button is fer! The funny thing about this button is that it will only work if the unit is turned off! Tried it during boot up and no way Jose! The button was like non responsive, just like when you tell your gf _not_ to go MNG just this once for your date. It only worked after I finally hunkered down to read the damn manual! Now, why didn't I just save myself the aggravation and did that from the beginning? Why? I don't know, I just want to be cool like everyone?!
At this point the lappie is working fine installed with a printer and a hax0red version of office 2007. Hey! don't be barking down this pair of pants asking why not openoffice! When the customer is your gf and she ain't in the mood of hearing about your FSS evangelism, you shut up and and nod man! The customer is always right, doubly so when she is your better half!
On the performance of this little guy I can only say this ... "It's slow and steady". Stuff works but there is just that little bit of lag before starting up, hey give it a break it's just that little atom of a processor under the hood man! I am quite happy with the performance considering that we only forked out Rm 1,783 with printer thrown in! I can see the appeal this kind of lappie would have for the ever on the go exec that just wants to occasionally check his/her mail or do the usual proposal on the run. For the rest of us that needs that performance juice from their daily machine, and do more than that stay clear!
Well, at least it's been fun and I am still in her good books :)
Labels:
general
Sunday, January 11, 2009
Gmail migration script done!
Hello there again! Nothing like a little good olde' scripting to usher in the new year. As most of you will recall I was working on a script to migrate email from an existing imap server on to google app. The only thing that my script needed to do was transform folders into labels. Easy peasy I thought sure someone else has encountered this. Boy, was I wrong. I could not for the life of me find anything of the sort out there!
Well, no matter. I proceeded to create my own script from scratch and after about 2 hours my script could already scan my existing imap server, list all the folders and re-create them as labels on my gmail account! It was then that I stumbled across this piece of genius xiao duo so graciously left of the web. Their script was made to migrate emails from an existing gmail account to another gmail account. I found that the script they had complemented mine to a T! Talk about Laws of Attraction!! Great! All I had to do now was to transplant my script using my vim scalpel on to my script and faster than you can say Fedora 10's release name I had a working super duper gmail migration script!
Everything works as it should. About the only drawback I noticed with my script was that with TmNut's great connection, the connection timed out on me a few times and after restarting the script it started screening the folders right from the top again. Maddening! This is one of the improvements I have noted down, but for now everything works just fine. I can't attach any code here, so if for some reason you need the script just drop me a comment or a line here.
Catch ya laterz.
Well, no matter. I proceeded to create my own script from scratch and after about 2 hours my script could already scan my existing imap server, list all the folders and re-create them as labels on my gmail account! It was then that I stumbled across this piece of genius xiao duo so graciously left of the web. Their script was made to migrate emails from an existing gmail account to another gmail account. I found that the script they had complemented mine to a T! Talk about Laws of Attraction!! Great! All I had to do now was to transplant my script using my vim scalpel on to my script and faster than you can say Fedora 10's release name I had a working super duper gmail migration script!
Everything works as it should. About the only drawback I noticed with my script was that with TmNut's great connection, the connection timed out on me a few times and after restarting the script it started screening the folders right from the top again. Maddening! This is one of the improvements I have noted down, but for now everything works just fine. I can't attach any code here, so if for some reason you need the script just drop me a comment or a line here.
Catch ya laterz.
Labels:
python
Subscribe to:
Posts (Atom)