I was having a really frustrating problem in that long-running queries to a (MS) SQL Server database were resulting in a TimeoutError being raised. After much research I determined that the issue was with the ADO driver's CommandTimeout property. It needed to be set to be much higher. From circumstantial evidence, it seemed to timeout after 30 seconds.
Setting that property via ActiveRecord was tricky. The property can be set directly against the underlying DBI database handle object. That object can be gotten at through the ActiveRecord::Base.connection object.
The name of my ActiveRecord model is IDX. So, I set the timeout with:
IDX.connection.instance_variable_get(:@connection).handle.instance_variable_get(:@handle).setproperty('CommandTimeout', 7200)
That works but, are you kidding me?!
Credit goes to the author of the blog at http://www.enterpriseetc.com/post/Ruby-in-Practice.aspx. His update at the very end ultimately pointed me in the right direction.
22 February 2008
19 February 2008
Moving to PostgreSQL
We had a mini-throwdown on database servers yesterday. After some research, we determined that we could not use MySQL in one of our commercial products without purchasing the commercial license for MySQL. That license costs $600/year/installation. That kind of money adds up over 40 installations.
Given that, we have decided to try using PostgreSQL instead. It is a robust database with plenty of good software APIs written around it. We need to be able to connect with it via PHP, Phython, Ruby, and ODBC and as far as I can tell, all of those will work just fine. PostgreSQL, besides being robust, is absolutely free for us to use in our commercial application without a requirement to open source the code. We have even decided to try using it in our custom applications too.
I spent some time in postgres yesterday and got up to speed quickly. It has a wealth of enterprise-worthy features but I'm sure that we won't be using those. If I'm wrong, then, hey, at least they are already in the server and we can scale up as needed. One explicit technology decision that my company has made is to use the back-end database simply as a data store and not to use its advanced features such as views, triggers, and stored procedures, unless it becomes necessary on a case-by-case basis. We are pushing all of that business logic into the application layer so that it will all be in one place and will be easily maintainable by multiple developers. The goal is for our code to be database agnostic. The trade-off is a sligtly slower application.
Now my issue is selecting getting an ORM for Python to work with both MySQL and PostgreSQL. More to come...
Given that, we have decided to try using PostgreSQL instead. It is a robust database with plenty of good software APIs written around it. We need to be able to connect with it via PHP, Phython, Ruby, and ODBC and as far as I can tell, all of those will work just fine. PostgreSQL, besides being robust, is absolutely free for us to use in our commercial application without a requirement to open source the code. We have even decided to try using it in our custom applications too.
I spent some time in postgres yesterday and got up to speed quickly. It has a wealth of enterprise-worthy features but I'm sure that we won't be using those. If I'm wrong, then, hey, at least they are already in the server and we can scale up as needed. One explicit technology decision that my company has made is to use the back-end database simply as a data store and not to use its advanced features such as views, triggers, and stored procedures, unless it becomes necessary on a case-by-case basis. We are pushing all of that business logic into the application layer so that it will all be in one place and will be easily maintainable by multiple developers. The goal is for our code to be database agnostic. The trade-off is a sligtly slower application.
Now my issue is selecting getting an ORM for Python to work with both MySQL and PostgreSQL. More to come...
28 January 2008
SOAP
I'm back on Ruby-ish stuff this week. The work I'm doing has a big SOAP component. The built-in Ruby SOAP library does quite well for my needs. It basically kicks the Python equivalent, ZSI, around the block.
Not that SOAP is the only web service in town but, for my projects, I have to use it because the upstream providers only offer SOAP.
Only a few more days until the season premiere of Lost! Yay!!!!
Not that SOAP is the only web service in town but, for my projects, I have to use it because the upstream providers only offer SOAP.
Only a few more days until the season premiere of Lost! Yay!!!!
25 January 2008
Test driven development
Well, I have been off on a major project that uses Python. Man, I love that language.
What has been great with this project is that I finally have enough comfort and experience with testing that I am naturally doing test-driven development. I don't feel good about my code unless I have reasonable tests in place.
What has been great with this project is that I finally have enough comfort and experience with testing that I am naturally doing test-driven development. I don't feel good about my code unless I have reasonable tests in place.
26 December 2007
Ruby's require is lacking
I wrote a Ruby gem recently and named the gem 'publication_search'. It contained a single module called 'Publication' which, in turn, contained a class hierarchy. One such class was named 'Search'.
To use this gem, once it is installed, one could type within a Ruby program or the irb:
The solution in this particular case is to rename the gem's module to something that is non-conflicting such as 'PublicationSearch'. But that's short-sighted because what if a Rails developer now wants to have a model named...you guessed it...PublicationSearch? The problem would be back.
It's not reasonable to rename the gem's module since the gem could be used widely in many different applications but the Rails app. only exists in one place even if it is distributed widely. It's also not reasonable to ask the Rails developer to rename his model so as not to conflict with the gem's module name.
Coming from the Python world, this kind of module namespace clash is a non-starter because you would simply write something like:
To use this gem, once it is installed, one could type within a Ruby program or the irb:
gem 'publication_search'The problem is that in Ruby on Rails, one may decide to define a model (a class) called Publication. If you then try to use my publication_search gem you'll get all sorts of errors. The issue is that because of the way that classes and modules are stored internally by the Ruby interpreter you cannot have a module and a class with the same name. (See this blog entry for the details.)
require 'Publication'
p = Publication::Search.new()
The solution in this particular case is to rename the gem's module to something that is non-conflicting such as 'PublicationSearch'. But that's short-sighted because what if a Rails developer now wants to have a model named...you guessed it...PublicationSearch? The problem would be back.
It's not reasonable to rename the gem's module since the gem could be used widely in many different applications but the Rails app. only exists in one place even if it is distributed widely. It's also not reasonable to ask the Rails developer to rename his model so as not to conflict with the gem's module name.
Coming from the Python world, this kind of module namespace clash is a non-starter because you would simply write something like:
import publication_search.Publication as PubSearchand this aliases the entire module as PubSearch. (You could alias it with whatever name you wanted -- I chose PubSearch.) From my research there does not appear to be anything analagous in Ruby. (If I am wrong, PLEASE let me know.)
p = PubSearch.Search()
17 December 2007
Goodbye Ubuntu
Ubuntu failed to run my VMWare images. That was a death sentence for Ubuntu for my laptop computer. It failed in other areas too which were not really its fault. XP went back onto my computer at 9am this morning. Bummer. XP is lame but at least all of my stuff will run on it.
In the end, I feel like I could have gotten everything working in Ubuntu...eventually. I just don't have time in my life for that kind of non-productive configuration work. There's no justification for that kind of time spent when I could be doing other things.
What a bitter ending...
In the end, I feel like I could have gotten everything working in Ubuntu...eventually. I just don't have time in my life for that kind of non-productive configuration work. There's no justification for that kind of time spent when I could be doing other things.
What a bitter ending...
13 December 2007
Ubuntu disaster
Previously, I had blogged that installing VMWare Server on Ubuntu would be no problem because I had installed it before on CentOS and it worked beautifully. Oh, cruel fate! Not only did it not go well but I had to reinstall Ubuntu from scratch. But first, a little of the backstory...
First off, I downloaded the tarball from VMWare, extracted, and installed from source. It went flawlessly, Next, I fired up VMWare Server and tried running one of my VMs. The guest VM was really slow. What's going on here? I did some googling and tried a few things but had no luck. My instinct was to turn off the host OS's graphical effects but I didn't do that for some reason.
OK, fine. I'll uninstall VMWare and then install the packages from Synaptic. Maybe they'll be optimized for Ubuntu. Well, they were but they also broke my XServer so that my graphics fell back to Windows 3.1 levels (aka VGA). The guest VM under VMWare ran at the correct speed but at the cost of messing up the host OS graphics. Grrr. I tried reinstalling the ATI drivers from Envy and the xserver-xgl packages but had no luck. I tried uninstalling VMWare but no luck.
Finally, in a fit of desperation early this morning, I decided to reinstall Ubuntu. After all, I had ironed out the kinks with configuring it already so it should go smoothly, right? It HAS NOT gone smoothly. I'm actually on my second reinstall since last night. This time, however, I have written down every step I had made in the configuration since I started. I'll post those up here if it makes sense.
I'm heading down the path of being a VMWare/Ubuntu/ATI hater. If I can't get this $#**#/ computer stable by next week, I'm going back to boring but stable XP for at least another year. I don't have time for this foolishness. By next year I'll have a new laptop, new graphics card, and Ubuntu will probably have released a new version.
A piece of advice...if you're in the office today you'd best avoid me since I feel like my temper is on a hair trigger!
First off, I downloaded the tarball from VMWare, extracted, and installed from source. It went flawlessly, Next, I fired up VMWare Server and tried running one of my VMs. The guest VM was really slow. What's going on here? I did some googling and tried a few things but had no luck. My instinct was to turn off the host OS's graphical effects but I didn't do that for some reason.
OK, fine. I'll uninstall VMWare and then install the packages from Synaptic. Maybe they'll be optimized for Ubuntu. Well, they were but they also broke my XServer so that my graphics fell back to Windows 3.1 levels (aka VGA). The guest VM under VMWare ran at the correct speed but at the cost of messing up the host OS graphics. Grrr. I tried reinstalling the ATI drivers from Envy and the xserver-xgl packages but had no luck. I tried uninstalling VMWare but no luck.
Finally, in a fit of desperation early this morning, I decided to reinstall Ubuntu. After all, I had ironed out the kinks with configuring it already so it should go smoothly, right? It HAS NOT gone smoothly. I'm actually on my second reinstall since last night. This time, however, I have written down every step I had made in the configuration since I started. I'll post those up here if it makes sense.
I'm heading down the path of being a VMWare/Ubuntu/ATI hater. If I can't get this $#**#/ computer stable by next week, I'm going back to boring but stable XP for at least another year. I don't have time for this foolishness. By next year I'll have a new laptop, new graphics card, and Ubuntu will probably have released a new version.
A piece of advice...if you're in the office today you'd best avoid me since I feel like my temper is on a hair trigger!
Subscribe to:
Posts (Atom)