Hi Guys,
Ruby imposes several way of connecting to Mysql (DBI,activerecord…)
Database using ruby code. Let me know if anybody knows how to connect to
mysql the easiest way.
I am getting all sorts of error trying to connect to mysql. I am using
Windows XP OS.
Hope to hear from you guys soon!!
Hi Guys,
Ruby imposes several way of connecting to Mysql (DBI,activerecord…)
Database using ruby code. Let me know if anybody knows how to connect to
mysql the easiest way.
Hi Guys,
Ruby imposes several way of connecting to Mysql (DBI,activerecord…)
Database using ruby code. Let me know if anybody knows how to connect to
mysql the easiest way.
You have to
gem install mysql
gem install dbd-mysql
gem install dbi
before using it.
HTH.
Hi,
On Trying, " gem install mysql " , i get the following error:
C:\Documents and Settings\user1\Desktop>gem install mysql
Building native extensions. This could take a while…
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
D:/Softwares/ruby/bin/ruby.exe extconf.rb
checking for main() in libmysql.lib… no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for mo
details.
Hi Guys,
Ruby imposes several way[s] of […] using ruby code.
That’s certainly an interesting observation.
Guys,
I eventually got it working, just adding gem ‘dbi’…
require “rubygems”
gem “dbi”
require “dbi”
def connect_to_mysql()
puts “\nConnecting to MySQL…”
me = DBI.connect(“dbi:Mysql:DBname:localhost”, “root”, “”)
query = me.prepare(“SELECT * FROM browsers where id > ?”)
query.execute(0)
while row = query.fetch() do
puts row
end
Thanks
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.