I want to copy data from one database to another using rails. But, it seems that rails only will talk to one database at a time. Is there a way around this? Any help would be greatly appreciated. -- Best Regards, -Larry "Work, work, work...there is no satisfactory alternative." --- E.Taft Benson -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060309/ed9776f8/attachment.html
> I want to copy data from one database to another using rails. But, it seems > that rails only will talk to one database at a time. Is there a way around > this?You should be able to explicitly connect to extra databases. Take a look at: http://wiki.rubyonrails.com/rails/pages/HowtoUseMultipleDatabases http://blogs.pragprog.com/cgi-bin/pragdave.cgi/Tech/Ruby/Connections.rdoc
Thanks for the links. The pragprog method of creating a LegacyBase parent model class, and having the other model classes inherit from it works. My parent class is something like this: class LegacyBase < ActiveRecord::Base establish_connection ... end Since this connection is used for importing data into my main database, should I worry about when it closes? or, maybe a better way to say this is: How can I closed the connection when it is no longer needed? On 3/9/06, brabuhr@gmail.com <brabuhr@gmail.com> wrote:> > > I want to copy data from one database to another using rails. But, it > seems > > that rails only will talk to one database at a time. Is there a way > around > > this? > > You should be able to explicitly connect to extra databases. Take a look > at: > > http://wiki.rubyonrails.com/rails/pages/HowtoUseMultipleDatabases > > http://blogs.pragprog.com/cgi-bin/pragdave.cgi/Tech/Ruby/Connections.rdoc > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Best Regards, -Larry "Work, work, work...there is no satisfactory alternative." --- E.Taft Benson -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060310/5f822615/attachment.html
On 3/9/06, Larry Kelly <larry@tellinkltd.com> wrote:> Since this connection is used for importing data into my main database, > should I worry about when it closes? > > or, maybe a better way to say this is: How can I closed the connection when > it is no longer needed?http://rubyonrails.org/api/classes/ActiveRecord/Base.html remove_connection(klass=self) Remove the connection for this class. This will close the active connection and the defined connection (if they exist). The result can be used as argument for establish_connection, for easy re-establishing of the connection.