Rake Task insert record from MySqlDB to SqlServerDB


#1

Hi,

Anyone can help, to my script see the list below. I want to insert from
MySqlDB to SqlServerDB. Currently, my script will insert the entire data
but I need to truncate the table first from SqlServerDB on ISQL command
line manually.

Is there a way directly to insert the data without truncating the table
mytalbes on SqlServerDB?

Start Here

rake utils:staging

n# rake utils:staging
namespace :utils do
task :staging => :environment do
FileList.new(‘app/**/*’) { |list|
translations = []
list.each { |file_path|
unless File::directory?(file_path)
file = File.open(file_path, ‘r’)
file.each { |line|
translations = translations |
line.scan(/’"[’"].t/)
}
file.close
end
}
# MySqlDB Unix getting the data here
ActiveRecord::Base.establish_connection(:development)
mytables = Mytable.find :all

    # SqlServerDB Windows insert the data not existing on MysqlDB

Unix
ActiveRecord::Base.establish_connection(:production)
mytables.each { |mytable| Mytable.create mytable.attributes }
}
end
end

End Here

Thanks in Advance!