Hi,
I have a small utility script that *should* grab some data from a mysql
database and then do stuff with it. It''s working on Mac OS 10.4 (with
mysql 4.something) but fails on the linux server that it''s supposed to
be deployed on which from memory is running mysql 3.23 (or there
abouts). Oh, to make matters worse, my mac is running ruby 1.8.4 and the
server is 1.8.2.
One other difference is that I can''t install the gem properly on the
linux box as I don''t have the right privledges, so the mysql lib is
being referenced as a file in the same directory. This seems to work, as
I can load a Mysql class ok and check out it''s functions.
The linux server seems to fail on the Mysql.rel_connect call, but
doesn''t get to the rescue - it fails in the ensure block with no method
error on dbh.close (dbh is nil).
Can anyone offer any advice on where to look - I know it''s a bit messy,
but I''m sure there''s some magic that can be done to get it
working!
By the way, I can''t get the mysql version on the linux server updated
as
it''s a shared server (but may be able to upgrade ruby to 1.8.4).
thanks,
Dan
code snippet
==========================================require "mysql"
begin
# connect to the MySQL server
dbh = Mysql.real_connect("localhost", "user",
"password", "db")
#nothing happens after here
res = dbh.query("SELECT * FROM pages")
while row = res.fetch_row do
home_stats << sprintf("%-1$*3$s %2$d\n", row[0],
row[1].to_i,
40)
home_total += row[1].to_i
end
res.free
rescue MysqlError => e
puts "error: #{e}" # <-- this line never gets called even though
dbh
is nil
ensure
# disconnect from server
dbh.close # <-- fails here because dbh is nil
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---