This is my full script.
I am trying to do a rake task that collects data from files in a directory and uploads it to mysql.
I set local-infile = 1, nothing works. It just gives me an error
namespace :db do namespace :load do desc "Load Properties into DB" task :properties => :environment do Mysql2::Client.default_query_options[:connect_flags] |= Mysql2::Client::LOCAL_FILES @files = Dir.entries("db/property_website_scripts/") connection = ActiveRecord::Base.connection() for file in @files next if file == "." || file == ".." sql = "LOAD DATA LOCAL INFILE '#{Rails.root}/db/property_website_scripts/#{file}' INTO TABLE properties FIELDS TERMINATED BY '|' LINES TERMINATED BY '\r\n' (property_type,property_for,city,state,country......);" connection.execute(sql) end
source share