title: Copy between databases in Rails console
body: <p>I have three databases: </p>
  
  <ul>
  <li>A. mynewapp_psql (Postgres)</li>
  <li>B. old_products_psql (Postgres)</li>
  <li>C. old_blogposts_mysql (Mysql)</li>
  </ul>
  
  <p>Each is defined in <code>database.yml</code></p>
  
  <p>I'm using <code>A</code> (<code>mynewapp_psql</code>) as the database for my new app. In this app I want to be able to copy selected material from my two older databases.</p>
  
  <p>My attempt (updated according to response)</p>
  
  <pre><code>old_db = ActiveRecord::Base.establish_connection(:database =&gt; 'old_blogposts_mysql'... etc)
  posts = old_db.connection.execute("select * from posts'")
  posts.each do |p|
    NewPost.create(:name =&gt; p.name.downcase) #NewPost should add Post in A. (mynewapp_psql)
  end
  </code></pre>
  
  <p>It should take each product from my old database and create a new equivalent in the new database.</p>
  
  <p>I really prefer doing it through the console and I can't copy the database straight over since I need to filter and alter the data.</p>