Different Database Engines

Could someone please clarify whether it’s possible for rails to use
two different databases at the same time within one application; for
example, I’ve a web application written in C# using MSSQL as the
database, and on the other hand I’m looking to write a ruby/rails
application using postgres as the database backend. I don’t want to
save data to the MSSQL database but simply query tables and work with
the results. Any database saving will occur only in postgres. So far
I haven’t been able to determine whether this is possible.

Thanks in advance

On Wed, Dec 19, 2007 at 07:13:54AM -0800, hiddenhippo wrote:

Could someone please clarify whether it’s possible for rails to use
two different databases at the same time within one application; for
example, I’ve a web application written in C# using MSSQL as the
database, and on the other hand I’m looking to write a ruby/rails
application using postgres as the database backend. I don’t want to
save data to the MSSQL database but simply query tables and work with
the results. Any database saving will occur only in postgres. So far
I haven’t been able to determine whether this is possible.

Yes, it’s possible, and fairly easy. Look at
ActiveRecord::Base.establish_connect (and google for
establish_connection
and rails for some good examples of its use).

Thanks in advance
–Greg

You should check out Active Delegate by Robby R.

http://www.robbyonrails.com/articles/2007/10/05/multiple-database-connections-in-ruby-on-rails

Good luck.
Mike