Created
February 16, 2011 21:23
-
-
Save ivanacostarubio/830244 to your computer and use it in GitHub Desktop.
Small script to get out of Wordpress. Don't be oppress by that shit!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'active_record' | |
ActiveRecord::Base.configurations['db1'] = { | |
:adapter => "mysql", | |
:host => "", | |
:database => "", | |
:username => "", | |
:password => "" | |
} | |
ActiveRecord::Base.configurations["db2"] = { | |
:adapter => 'mysql', | |
:database => '', | |
:username => '', | |
:host => '' | |
} | |
class Wp_posts < ActiveRecord::Base | |
establish_connection "db1" | |
end | |
class Post < ActiveRecord::Base | |
establish_connection "db2" | |
end | |
old_posts = Wp_posts.all | |
old_posts.each do |old_post| | |
post = Post.create(:title => old_post.post_title, :body => old_post.post_content) | |
puts post.save | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment