Forum: Ruby on Rails How to copy between databases?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Larry K. (Guest)
on 2006-03-10 00:17
(Received via mailing list)
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
unknown (Guest)
on 2006-03-10 00:23
(Received via mailing list)
> 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/HowtoUseMu...
    http://blogs.pragprog.com/cgi-bin/pragdave.cgi/Tec...
Larry K. (Guest)
on 2006-03-10 02:18
(Received via mailing list)
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, removed_email_address@domain.invalid 
<removed_email_address@domain.invalid> wrote:
>     http://wiki.rubyonrails.com/rails/pages/HowtoUseMu...
>
> http://blogs.pragprog.com/cgi-bin/pragdave.cgi/Tec...
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>



--
Best Regards,
-Larry
"Work, work, work...there is no satisfactory alternative."
            --- E.Taft Benson
unknown (Guest)
on 2006-03-10 18:24
(Received via mailing list)
On 3/9/06, Larry K. <removed_email_address@domain.invalid> 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.
This topic is locked and can not be replied to.