published 3 months ago (21.07.2008 00:19)
loading data from mysql into couchdb with rest and ActiveRecord
$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