diff --git a/Pearlception/config/database.yml b/Pearlception/config/database.yml index d5624af..025b1d5 100644 --- a/Pearlception/config/database.yml +++ b/Pearlception/config/database.yml @@ -13,9 +13,6 @@ default: &default adapter: mysql2 encoding: utf8 pool: 5 - username: <%= ENV['TEST_USER'] %> - password: <%= ENV['TEST_PASS'] %> - socket: <%= ENV['TEST_SOCKET'] %> stats_development: &stats adapter: mysql2 @@ -34,8 +31,8 @@ stats_test: development: <<: *default database: Pearlception_development - username: root - password: Kemitscafe1 + username: bmv + password: 1156244terps! # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". @@ -43,8 +40,8 @@ development: test: <<: *default database: Pearlception_test - username: root - password: Kemitscafe1 + username: bmv + password: 1156244terps! # As with config/secrets.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is diff --git a/migrate.rb b/migrate.rb new file mode 100644 index 0000000..a60ee60 --- /dev/null +++ b/migrate.rb @@ -0,0 +1,40 @@ +#Script to migrate things to the bmv server from a csv file + +require 'mysql2' +require 'csv' + + +class Run + + attr_accessor :id, :run_date, :location, :harvest_time, :supplier, :distributor, :other, :machine_id + + def initialize(id, run_date, location, harvest_time, supplier, distributor, other, machine_id) + @id = id + @run_date = run_date + @location = location + @harvest_time = harvest_time + @supplier = supplier + @distributor = distributor + @other = other + @machine_id = machine_id + end + +end + +client = Mysql2::Client.new( + #INSERT LOGIN INFO HERE + ) +runs = [] +CSV.foreach("#{ARGV[0]}") do |row| + runs.push(Run.new(*row)) unless row[0] == "run_id" +end +runs.each do |run| + puts run.inspect + query = "INSERT INTO runs (id, runDate, location, harvest_time, supplier, distributor, + other, machine_id, created_at, updated_at) + VALUES + (#{run.id},NOW(), \"UMD\" ,\"#{run.location}\",\"#{run.supplier}\", + \"#{run.distributor}\",\"\",1,NOW(),NOW());" + res = client.query(query) + puts res +end