loading data from mysql into couchdb with rest and ActiveRecord

Posted by phillip Sun, 20 Jul 2008 22:19:00 GMT

$KCODE = 'u'

require 'rubygems'
require_gem 'activerecord'
require 'rest_client'

class MyModel < ActiveRecord::Base
end

ActiveRecord::Base.establish_connection(
  :adapter => "mysql", 
  :database => "hello_world", 
  :encoding => 'UTF8'
)

MyModel.find(:all).each do |record|
  p RestClient.post('http://localhost:5984/hello_world', record.to_json)
end

Posted in , | Tags , , , , ,