Forum: Ruby on Rails Rake Task insert record from MySqlDB to SqlServerDB

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Rake N. (Guest)
on 2009-02-17 11:33
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!
This topic is locked and can not be replied to.