views:

32

answers:

0

I've been working on a ruby module that interacts with mysql on my server. I need to fetch and write data to the database, and it's been working fine for a while now. However, today I created a new file trying to access the database and it wouldn't run. When I tried to execute it (with command: ruby mysql.rb), I received the following error message:

./mysql.rb:12: uninitialized constant Mysql (NameError)
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
require'
from mysql.rb:2

This is very odd, because I've never had this problem before, and unfortunately I couldn't find any relevant solutions to the problem online. I don't think it's a problem with my code, but here it is anyway:

require 'mysql'  
$host = 'localhost'  
$user = 'root'  
$pswd = 'password'  
$base = 'base'  
$db = 'database'  

dbh = Mysql.real_connect($host,$user,$pswd,$base)
keys = dbh.query("SELECT source, keyword, group FROM #{$db}")
    keys.each do |key|
        printf "%s, %s\n", key[0], key[1]
    end
keys.free

I'm thinking there may be a problem with the server, or something may have been changed recently without my knowledge (I am not the only developer on this server). I uninstalled and reinstalled the mysql gem, but it didn't help. The server is running Ubuntu 10.04 LTS, kernel revision 2.6.32-22-generic. Here is the full list of local gems (Note that rails is installed on the server, but this particular module is not running on rails. It's just a script that runs on its own, directly from the shell.):

actionmailer (2.3.8, 2.3.5)
actionpack (2.3.8, 2.3.5)
activerecord (2.3.8, 2.3.5)
activeresource (2.3.8, 2.3.5)
activesupport (2.3.8, 2.3.5)
builder (2.1.2)
cgi_multipart_eof_fix (2.5.0)
daemons (1.1.0)
factory_girl (1.3.2)
fastthread (1.0.7)
feedtools (0.2.29)
gem_plugin (0.2.3)
hpricot (0.8.2)
mechanize (1.0.0)
mongrel (1.1.5)
mysql (2.8.1)
nokogiri (1.4.3.1)
passenger (2.2.15, 2.2.14)
rack (1.2.1, 1.1.0, 1.0.1)
rails (2.3.8, 2.3.5)
rake (0.8.7)
rubygems-update (1.3.7)
uuidtools (2.1.1)

Does anyone have an idea about what might be wrong? I would really appreciate any feedback you guys have.

Thanks,
Scribbler