2 different databases in 1 application? MySQL & Informix

Please, i need help.

i wonder if rail allows to have 1 legacy database in informix and other
mysql database (no legacy) in the same application.

I need to query in the informix database and manipulate data to save in
mysql.

It is posible?? if it is, how? any guide? tutorial? link?

I’ll appreciate any help.

best regards.

Mary,
Baja California

Soon Baja 1000!

sure…look at the docs for ActiveRecord::Base.establish_connection

If you google on something like “multiple databases in rails” you will
find many examples. You can also store your db information in
database.yml and refer to it by name with establish_connection

-Bill

Mary Nu wrote:

I’ll appreciate any help.

best regards.

Mary,
Baja California

Soon Baja 1000!


Sincerely,

William P.

Hi Mary,

I’ve got one similar project where I perform some queries on a legacy
MS SQL database and use a (new) My SQL database to manage the newer
part of the system. It is possible and it works OK. I had to go
through a few nightmares with MS SQL / RoR (bugs in the adapter,
problems with specific field types, problems with pagination, etc),
but I got it to do what I need.

The way I’m doing it is pretty simple, no plug-in, all based on pure
rails. This is how:

  1. in you models pointing to the legacy database, you might need to
    specify table names and primary key columns as they probably wont
    follow RoR default naming conventions:

class Consultants < External
set_table_name “Consultants”
id = “ConsIntID”

 .....

end

You can also see that I’m deriving Consultants from “External”. This
is how the External model looks like:

class External < ActiveRecord::Base
self.abstract_class = true
establish_connection :yourlegacydb
end

Then you can have any model pointing to the legacy DB derived from
External, and you can configure your connection to your legacy db in
your database.yml file just like this:

yourlegacydb:
adapter : …

Good luck,
Seb

Quick google search turned up this:

http://wiki.rubyonrails.org/rails/pages/HowtoUseMultipleDatabases

Mary Nu wrote:

I’ll appreciate any help.

best regards.

Mary,
Baja California

Soon Baja 1000!


Sincerely,

William P.

Thanks a lot sbrocher. I already make a test and it works.