0

In my Rails app, I should import data beetwen two database. I would make a select on MS SQL Server(external server), then insert into SQLite (embedded)

To connect to SQL Server i'm using "tiny_tds" and "activerecord-sqlserver-adapter" gem's and select is working fine.

The code to do this :

def fetch_rows
  client = TinyTds::Client.new(username: 'MyUser', password: 'foo', host: 'MyServer', database: 'MyDB')
  client.execute("SELECT id_person, name, surname FROM [MyDB])
end
  • Now, how could I "INSERT INTO" my data in SQLite ?
  • Is "SQL way" the right way ?
  • Did you know something easier ?
  • Very important, it's a daily update, not just one shot !

Many thanks in advance for your help !

Nicolas

Nicolas R
  • 55
  • 6
  • Here you could find useful information: http://stackoverflow.com/questions/6122508/connecting-rails-3-1-with-multiple-databases – Yevgeniy Anfilofyev Sep 17 '13 at 14:28
  • I would create abstract classes (that use a non-default database connection) for each different database connection. (Or have one database be the primary database for the Rails app and have the 2nd database be an abstract connection). If you do this, you can basically ignore the differences between the databases because ActiveRecord will abstract everything for you. – Teddy Sep 17 '13 at 14:48
  • See http://stackoverflow.com/questions/1281310/any-suggestions-for-a-ruby-solution-for-populating-a-sqlite-database-from-a-mysq – knut Jun 10 '16 at 12:47

0 Answers0