0

I have an app that has been running for years. We then migrated the server to Ubuntu 15.04 and installed Ruby.

sudo apt-get install curl
sudo apt-get install ruby2.1
sudo gem update --system
sudo apt-get install rake
apt-get install ruby-dev
sudo gem install amatch
sudo apt-get install libmysqlclient-dev
sudo gem install -r dbi
sudo gem install -r mysql dbd-mysql

Then we ran the program and get this err..

/var/lib/gems/2.1.0/gems/dbi-0.4.5/lib/dbi.rb:300:in `block in load_driver': Unable to load driver 'MySQL' (underlying error: uninitialized constant DBI::DBD::MySQL) (DBI::InterfaceError)
    from /usr/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
    from /var/lib/gems/2.1.0/gems/dbi-0.4.5/lib/dbi.rb:242:in `load_driver'
    from /var/lib/gems/2.1.0/gems/dbi-0.4.5/lib/dbi.rb:160:in `_get_full_driver'
    from /var/lib/gems/2.1.0/gems/dbi-0.4.5/lib/dbi.rb:145:in `connect'

The program itself (with user name and pw changed)

#!/usr/bin/ruby
require "rubygems"
gem 'mysql'
gem 'dbi'
require "dbi"
require "amatch"

include Amatch

name_sub = {    "unit"          => "un",
                "unt"           => "un",
                "tract"         => "tr",
                "estate"        => "est",
                "university"    => "univ",
                "trust"         => "trst"  }

op_sub = {      "partnership"   => "PS",
                "partnershp"    => "PS",
                "partner"       => "PS",
                "prtnr"         => "PS",
                "ptnr"          => "PS",
                "ptnrsp"        => "PS",
                "corporation"   => "C",
                "corp"          => "C",
                "company"       => "co",
                "incorporation" => "I",
                "inc"           => "I",
                "oil"           => "O",
                "gas"           => "G",
                "exploration"   => "E",
                "production"    => "P",
                "operating"     => "oper",
                "energy"        => "engy",
                "management"    => "mgmt",
                "resources"     => "res",
                "minerals"      => "min",
                "petroleum"     => "pet"  }


def mangle(s, dictionary = {})
  return "" unless s
        # lowercase | special case        | alphanumerics only
        s.downcase().gsub(/l.l.c./, 'llc').gsub(/\W/, " ").split(" ").map do |word|
    dictionary.fetch(word, word)
  end.join(' ')
end

stop_attempts = -1
PRODUCTION = false

begin
        # now the actual code



  # development database
  DBI.connect("dbi:MySQL:database=matching;" "host=enus", "mott", "bM^7ezOqYyn") do |outdb|
  DBI.connect("dbi:MySQL:database=ownership;" "host=enus", "mott", "bM^7ezOqYyn") do |lease_db|

  # re-create phase3 table
    outdb.do("drop table if exists phase3")
    sql = "create table phase3 (" +
      "id bigint not null auto_increment primary key, " +
      "lod_id bigint, rrc_id bigint, district varchar(255), " +
      "name_percent float, rrc_lease_no varchar(255)," +
      "op_percent float, field_percent float, total float, " +
      "key k1 (lod_id), key k2 (rrc_id), key k3 (district), " +...

An exhaustive Google search found recommendations of installing dbd-mysql, and other suggestions but none worked.

So what is failing here? I'm not a Ruby guy, I'm a lowly IT guy trying to get this back up and running.

2 Answers2

1

Looks like there are some issues with case sensitive filesystems here trying this on my mac, but I was able to get a test working by changing the connection string from "MySQL to "Mysql", example:

2.1.5@test_dbi ~$ cat test_dbi.rb 
#!/usr/bin/ruby
require "rubygems"
require 'dbi'
DBI.connect("dbi:Mysql:database=matching;" "host=enus", "mott", "bM^7ezOqYyn") 
2.1.5@test_dbi ~$ 
Trent Lloyd
  • 1,832
  • 1
  • 15
  • 13
  • Still get an error after changing case- /var/lib/gems/2.1.0/gems/dbi-0.4.5/lib/dbi.rb:300:in `block in load_driver': Unable to load driver 'Mysql' (underlying error: uninitialized constant DBI::DBD::Mysql) (DBI::InterfaceError) from /usr/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize' from /var/lib/gems/2.1.0/gems/dbi-0.4.5/lib/dbi.rb:242:in `load_driver' from /var/lib/gems/2.1.0/gems/dbi-0.4.5/lib/dbi.rb:160:in `_get_full_driver' from /var/lib/gems/2.1.0/gems/dbi-0.4.5/lib/dbi.rb:145:in `connect' – NonReformed Bayesianist May 13 '15 at 14:15
0

Solved the problem.

The core failure is bad code on Ruby 2.1.0 itself. See here to fix Ruby itself. [DBI Row / delegate behavior between ruby 1.8.7 and 2.1

Once I started getting an error, I changed the DBI call of Mysql to MySQL hoping to fix it, but that just caused another problem.

Community
  • 1
  • 1