how do i load a csv file in rails from a migrate usiing load data local infile ?
- by Chris Drappier
Hi All,
I have my csv file in my public folder, and i'm trying to load it from a migration, but I get a file not found error using this script :
ActiveRecord::Base.connection.execute(
"load data local infile '#{RAILS_ROOT}/public/muds_variables.csv' into table muds_variables " +
"fields terminated by ',' " +
"lines terminated by '\n' " +
"(variable_name, definition)")
I've checked and re-checked the file path, and that's definitely where it lives, I've also tried it just using the file name without any of the path, and a few other combos, but I can't make it work :(. can anyone help me out with this?
here's the error :
Mysql::Error: File '/home/chris/rails_projects/muds/public/muds_variables.csv' not found (Errcode: 2): load data local infile '/home/chris/rails_projects/muds/public/muds_variables.csv' into table muds_variables fields terminated by ',' lines terminated by ' ' (variable_name, definition)
-C