Ruby-on-rails – Execute sql script inside seed.rb in rails3

ruby-on-railsseed

I want to execute this sql script inside my seed.rb

LOAD DATA LOCAL INFILE '/home/list-38.csv'
INTO TABLE list
FIELDS TERMINATED BY ':'
LINES TERMINATED BY '\n'
(email,name,password);

I checked this link but unable to figure out the solution.So that once we run rake db:seed

How to seed mysql database by running sql scripts in Ruby Rails platform? it dumps my data into the table.

any queries ..do reply

Thanx

Best Answer

Try this in db/seeds.rb to execute raw SQL with rake db:seed

connection = ActiveRecord::Base.connection()
connection.execute("*_YOUR_SQL_HERE_*")
Related Topic