From: Ralph Smith Date: 2005-10-19T18:31:58+09:00 Subject: Re: mysql & ruby on windows? On Wed, 19 Oct 2005 09:51:46 +0900, James Britt wrote: >Ralph Smith wrote: >> The only instructions for getting ruby to access mysql that I've been able to find seem to be >> oriented to non-windows os's. The instructions talk about mysql c api header files, but I can't find >> them. Can someone tell me how to get ruby on windows xp to talk to mysql? >> > > >Simplest way is to get the pure-Ruby MySQL binding. > >http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/136505 > >Sort of old, but generally correct. > > > >James Britt I followed these instruction. 1) Download ruby-mysql-0.2.5.tar.gz from http://www.tmtm.org/en/ruby/mysql/README_en.html. This link is bad, but I found ruby-mysql-0.2.6.tar.gz at http://raa.ruby-lang.org/project/ruby-mysql/0.2.6 2) Unzip this file. I did this. This is what is confusing. The README_en.html in this says to: % ruby ./setup.rb % ruby ./test.rb hostname user passwd # ruby ./install.rb If I run 'ruby ./setup.rb' I get an error message: ../setup.rb:8:in ``': No such file or directory - mysql_config --socket (Errno::E NOENT) from ./setup.rb:8 So, I abandoned following these instructions, since the instructions don't mention needing to do this anyway. 3) Copy mysql.rb to $RUBY_HOME\lib\ruby\1.8. I did this. I then tried the sample code on the instruction page, with a valid username, password, database and table, but it doesn't connect and goes to the rescue code. So, I still would like to get mysql working with ruby on windows xp. What am I doing wrong? Sample code: require 'mysql' host = 'localhost' username = 'root' password = '' database = 'music' begin conn = Mysql.new(host, username, password, database) puts "connected" <<<<<<<<<<<<<<<<<<< DOESN'T GET HERE rs = conn.query('select * from artists') column_name = 'name' rs.each_hash do |row| puts "name = #{row[column_name]}" end rescue Mysql::Error => e #puts "Error! #{e.err}" puts "error here" <<<<<<<<<<<<<<<<<<<< GETS HERE ensure conn.close if conn end thanks, Ralph